Root password recovery in Linux

Root password recovery in Linux

Password forgetting and losing access to a Linux host can be a nightmare for anyone , but it happens to the best of us, in short if you ever lose your access to a linux machine i.e by forgetting its root password, then worry not! We have got your back.

editing grub to recover root

Reboot your server and during the boot screen choose “Advanced Options” from the Grub.

While on “Advanced Options” , press e to enter the editing mode for this option, and then change ro to rw in this command and add `init=/bin/bash` at the end of this line exactly.

Now press F10 and the following screen will then appear

At this screen we need to mount our system as read-write to make sure changes are implemented.

mount -n -o remount,rw /

Now to change the password enter following command:

passwd root

After entering above command, type your password (Note: you wont see it in the shell but it will be prompted twice). Also change root to any other username of your choice to change the password for that specific user, forexample passwd ehsan will change password for username ehsan.

 

Good Luck!

As rated by readers
[Total: 0 Average: 0]
0

Related Posts

Leave a Reply

avatar
  Subscribe  
Notify of