Forgotten Root Password

So you have forgotten the root password for Linux and so can't get into your system. Well all is not lost as you may still be able to get in and reset the password. How you might go about doing this depends on your Linux distribution and the boot loader that you are using.

With LILO you can try to boot into single user maintainance mode by typing linux 1 or linux single at the boot prompt. With GRUB you need to select which of the boot menu entries you wish to use and then press E to edit it to append 1 or single to the end of the command, press enter to stop editing and then B to boot.

If your distribution still requires a password to access runlevel 1 then you need to add init=/bin/bash to the end of the command instead. This will boot your system to a command prompt without running the startup scripts. This means that you will need to manually remount the root file system as read/write using the command mount -o remount,rw /.

Once you have succeeded in booting your system to a command prompt you can then edit the /etc/shadow file to remove the encrypted password field (usually the second field on the first line). You can then reboot your system and then use the passwd command to set a new root password.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow