Reset lost root password
This guide will show you how to reset a forgotten root password. Several methods are listed to help you accomplish this.
If you have installed sudo and have configured permissions for either the
wheel group or a user whose password you recall, you can change the root password by running
sudo passwd root.
Using a LiveCD
With a LiveCD a couple methods are available: change root and use the
passwd command, or erase the password field entry directly editing the password file. Any Linux capable LiveCD can be used, albeit to change root it must match your installed architecture type. Here we only describe how to reset your password with chroot, since manual editing the password file is significantly more risky.
- Boot the LiveCD and mount the root partition of your main system.
- Use the
passwd --root MOUNT_POINT USER_NAMEcommand to set the new password (you will not be prompted for an old one).
- Unmount the root partition.
- Reboot, and enter your new password.
Using bash as init
- Append the
init=/bin/bashkernel parameter to your boot loader's boot entry.
- Your root file system is mounted as read-only now, so remount it as read/write:
mount -n -o remount,rw /.
- Use the passwd command to create a new password for the root user.
- Reboot by typing
reboot -fand do not lose your password again!