Distroname and release: CentOS

Reset root password

OK, so you have lost your password to your computer, or one of your clients in the network, and you need to reset the root password? Then please continue reading, it is a very simple task, at least if you are running GRUB.

The boot process

When GRUB starts, press [e], to your currently used kernel to edit the boot parameter.

Now in the line starting with "kernel" add the word "single" to the end of the line. In some cases, it is needed to add "single init=/bin/bash".

The process differs a little from GRUB to GRUB2.
In GRUB press [e] to edit the line, and then press [enter] when done. Press [b] to boot with the changes.
In GRUB2 press [e] to edit the line, and then press [CTRL]+[X] to boot after the changes.

Example of the GRUB line after the change:
kernel /vmlinux-2.6.18-164.15.1.e15 ro root=/dev/VolGroup00/LogVol00 single
If you are prompted for a CTRL-D input to continue, you will need to add the init=/bin/bash as well.
kernel /vmlinux-2.6.18-164.15.1.e15 ro root=/dev/VolGroup00/LogVol00 single init=/bin/bash
If you have done it the correct way it should boot directly to the shell as root, without the need of typing any password. Now remount the system, so you have write access.This is not always this is needed, but if you have problems when setting a new password, please do it.
#mount -o remount,rw /
Now it is time to create a new password, simply execute the following command.
Finally make sure that the changes are written to the harddisk before we reboot.
#init 6
Now let it boot up completely, and you should be ready to go with the new password.


If this fails, in example if there is a GRUB password, then it should be possible by bootfrom from a live CD (in example knoppix, or the debian live CD), mount the partition where /etc/ is located on the system that we need to reset the root password, then chroot to the new mount point, and execute the passwd command to change the password. Now the /etc/shadow file on the system should be updated!
Copyright LinuxLasse.net 2009 - 2017 All Rights Reserved.

Valid HTML 4.01 Strict Valid CSS!