[FrontPage] [TitleIndex] [WordIndex

This is a read-only archived version of wiki.centos.org

Resetting a Forgotten Root Password

If you have forgotten the root password it is possible to set a new one as follows:

CentOS-6 instructions (also for CentOS 5):

Interrupt the boot at the GRUB stage when you see the menu that says "Booting CentOS (2.6.32-...) in X seconds" and boot to runlevel 1, AKA single user mode by doing the following.

This will give you a root shell and not a login prompt. From there you can use the "passwd" command to set a new root password.

Other user passwords can be reset, and other administrative tasks can be performed as well. Exiting the single user root shell by pressing Ctrl-D will boot to the multi-user mode defined in /etc/inittab.


For CentOS-7 and CentOS-8 please follow the upstream instuctions: https://www.redhat.com/sysadmin/recover-root-passwd

If SELinux is enforcing and the upstream instructions tell you to do so, then do not forget to relabel your filesystem afterwards or you will not be able to login until you reboot and repeat the instructions and include the autorelabel


2023-09-11 07:23