CENTOS 7 ROOT PASSWORD RESET

1 – Go to the boot grub menu select option to edit i.e, press the key “e”

Selection_003

2 – Go to the word “ro” as shown in the screen below

Selection_005

3 – Change “ro” to “rw init=/sysroot/bin/sh” as shown below

Selection_006

4 – Now press Control+x to start on single user mode.

Selection_007

5 – Now access the system with this command.

chroot /sysroot

6 – Reset the password.

passwd root

7 – Update selinux information

touch /.autorelabel

8 – Exit chroot

exit

9 – Reboot your system

reboot
Advertisements

.bashrc linux tip/hack

.bashrc linux tip/hack

Add the below lines of bash script code to your .bashrc file & then you can start using the command:
$ extract <ANY_ARCHIVE_FILE_NAME>

extract () {
   if [ -f $1 ] ; then
       case $1 in
           *.tar.bz2)   tar xvjf $1    ;;
           *.tar.gz)    tar xvzf $1    ;;
           *.bz2)       bunzip2 $1    ;;
           *.rar)       unrar x $1      ;;
           *.gz)        gunzip $1       ;;
           *.tar)       tar xvf $1       ;;
           *.tbz2)      tar xvjf $1    ;;
           *.tgz)       tar xvzf $1    ;;
           *.zip)       unzip $1       ;;
           *.Z)         uncompress $1  ;;
           *.7z)        7z x $1        ;;
           *)           echo “don’t know how to extract ‘$1’…” ;;
       esac
   else
       echo “‘$1’ is not a valid file!”
   fi
 }

Install Python Version 3.5 in Ubuntu

Install Python Version 3.5 in Ubuntu

# sudo apt-get install build-essential checkinstall -y
# sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -y

# sudo wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
If the link doesn’t work go to http://www.python.org and search for the latest version of python to download

# sudo tar xzf Python-3.5.2.tgz

# cd Python-3.5.2

# sudo ./configure

# sudo make altinstall

# python3.5 -V

Ansible Facts Variables usage tutorial

Ansible Facts Variables usage tutorial

Ansible Version: 2.1.0.0

Inventory File: inventory

This is the content of the file: “inventory

[elasti]
192.168.61.100
192.168.61.101
192.168.61.102
[elasti:vars]
ansible_user=stark
ansible_ssh_pass=12345

===================================================================

Template File: sample_template.j2

This is the content of the file: “sample_template.j2

{% for host in groups[‘elasti’] %}
{{ host }}
{% endfor %}

{{ hostvars[groups[‘elasti’][0]][‘ansible_eth0’][‘ipv4’][‘address’] }}
{{ hostvars[groups[‘elasti’][1]][‘ansible_eth0’][‘ipv4’][‘address’] }}
{{ hostvars[groups[‘elasti’][2]][‘ansible_eth0’][‘ipv4’][‘address’] }}

{{ hostvars[groups[‘elasti’][0]][‘ansible_eth1’][‘ipv4’][‘address’] }}
{{ hostvars[groups[‘elasti’][1]][‘ansible_eth1’][‘ipv4’][‘address’] }}
{{ hostvars[groups[‘elasti’][2]][‘ansible_eth1’][‘ipv4’][‘address’] }}

discovery.zen.ping.unicast.hosts: [{% for host in groups[‘elasti’] %}”{{ host }}”,{% endfor %}]

============================================================================

Playbook File: play.yml

This is the content of the file: “play.yml


– hosts: elasti
gather_facts: yes
become: yes
tasks:
– name: copy template into config file
template: src=sample_template.j2 dest=/tmp/output.txt

===========================================================================

Command: ansible-playbook play.yml -K

Output File: /tmp/output.txt

This is the content of output generated of file: /tmp/output.txt

192.168.61.100
192.168.61.101
192.168.61.102

192.168.61.100
192.168.61.101
192.168.61.102

10.0.3.15
10.0.3.15
10.0.3.15

discovery.zen.ping.unicast.hosts: [“192.168.61.100″,”192.168.61.101″,”192.168.61.102”,]

============================================================================

Reference Link: http://docs.ansible.com/ansible/faq.html