This article provides step by step instructions on how to recover/reset lost or forgotten RHEL 8 / CentOS 8 Linux root administrative password. To recover the root password you will first boot to the GRUB menu and perform a break at early stage of the boot process. Afterwards, you will remount the
sysroot directory with read & write access and change the root password on RHEL 8 / CentOS 8 by using the
passwd command to set the new root password.
In this tutorial you will learn:
- How to perform a break at an early stage of the boot process.
- How to remount root partition with read/write access.
- How to change root password.
- How to force filesystem relabeling.
Software Requirements and Conventions Used
|Category||Requirements, Conventions or Software Version Used|
|System||RHEL 8 / CentOS 8|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to recover RHEL 8 / CentOS 8 root password step by step instructions
- Boot to the GRUB menu and enter the edit mode. Use your arrows to navigate to the the menu item you would normally boot your RHEL 8 Linux system from. Press
eto start editing the selected menu item.
- Perform a break at an early stage of the boot process by typing
rd.breakat the end of the line starting with
kernel=. Once ready press
CTRL+Xto start the RHEL 8 boot process.
- Check write access on the
/sysrootmount point. By default this mount point is mounted only with the read-only (ro) access. Execute:
switch_root:/# mount | grep sysroot
- Remount the
sysrootdirectory with read & write access. To do so execute:
switch_root:/# mount -o remount,rw /sysroot/ switch_root:/# mount | grep sysroot
- Enter chroot system by executing:
switch_root:/# chroot /sysroot
- Use the
passwdcommand to set a new root password. Please note that when typing a new password the characters you type will not be visible. Simply keep typing.
- Force file-system relabeling by executing the following command:
# touch /.autorelabel
- Exit the
chrootsystem by executing the
- Logout to continue the normal boot:
- Wait for the file-system relabeling to complete. Depending on your system speed and number of files this might take some time. Be patient.
- Login with your new root password.