Monday, January 9, 2012

Forgot the root password of your linux box ?


So you forgot your root password of your linux box?, well its not the end of the world if you do have physical / KVM over IP access to your box, you can start it on single user mode and reset it. Don’t know how?… then read on.

In all honesty, this fix really depends on which boot loader your box is running. Normally on modern Linux distros the loader will be GRUB.

In this case, how to get into single user mode using Grub boot Loader?

Restart your box, and when the GRUB splash screen appears follow these steps:
  1. Select/highlight the kernel you wish to boot using the up/down arrow keys.
  2. Press the e key to edit the entry.
  3. Select/highlight the line starting with the word kernel.
  4. Press the e key to edit the line.
  5. Append the letter S to the end of the line.
  6. Press ENTER to accept the changes.
  7. Press the b key to boot the kernel with the modified command line.
This will take you into single user mode and should provide a bash shell to execute commands.
From this point on you probably can use the passwd command to change the root password.
In you are using the LILO boot loader, when you see the LILO screen press CTRL+X, you will see boot propmt
boot:
Here after boot: type
linux single
This will boot the system in single user mode. When you reach the # prompt, type:
passwd root
Once you reset the password you can then type init 3 or init 5. init 3 will start multi user boot without X and init 5 will start multi user mode with X/


If LILO is not set to wait at the boot menu, you can halt the boot process by pressing any key in the split second before lilo tries to boot the kernel.
By the way, in case you want to change the lilo timeout value, you can do it from:
/etc/lilo.conf  ( 0 means no wait )
once changed type:
lilo -v

No comments:

Post a Comment

Post a Comment