Article by Mohan Cheema
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
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


Doesn’t work
Thx bye
Booting into single user mode won’t necessarily drop you into shell, OpenSuSE/SuSE will present you with a login prompt. To get around this you need to append init=/bin/bash to the grub command line.
This will not always work, but this will:
In the kernel line change ‘ro’ to ‘rw’ and then add ‘init=/bin/bash’ to the end of the kernel line then boot it up.
You will then get a root prompt.. change pass with ‘passwd root’ then hit ctrl-d or type exit to cause a snazzy lil kernel panic and then reboot the machine.
You should now be able to log in with your new password. Enjoy!!
(tested on 4 different distros and works on them all)
Thanks for the info
For as far as grub is concerned, this should not work ! On a properly configured system grub should be password protected, so command line editing only becomes possible after authentication. The only way to get around that is booting the system in rescue mode from CD or DVD, chroot to your systemimage and use passwd to change the password. If the BIOS is password protected, so the boot sequence cannot be changed to make that possible, you will have to open the case to reset the BIOS password (jumper setting/removing battery), and even that is not possible on some systems.
Just extract the hard drive and edit /etc/passwd and /etc/shadow. You’ll need a usb-to-sata adapter, and a spare computer.
The least you could do in terms of owning spare computers is not throwing away your fully functional old PC (or laptop) that you should throw away.
This definitely doesn’t work on all distros… Can someone tell how can I change root password in Ubuntu ? tried everything….
Hello Rahu,
have you tested what posted in J_b14z3 comment ?
Boot with any install or live cd, mount the hard disk, chroot to it, mount proc (not necessary), passwd -d root, sync, exit, reboot