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:
- Select/highlight the kernel you wish to boot using the up/down arrow keys.
- Press the e key to edit the entry.
- Select/highlight the line starting with the word kernel.
- Press the e key to edit the line.
- Append the letter S to the end of the line.
- Press ENTER to accept the changes.
- 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
Here after boot: type
This will boot the system in single user mode. When you reach the # prompt, type:
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: