How To Reset Root Password on CentOS 7

Restart your CentOS 7 system. During the reboot, press ‘e’ on the GRUB menu to enter the boot configuration.

Reboot the System

In the GRUB editor, locate the line starting with "linux16" or "linux". Add rd.break at the end of this line.

Edit the Configuration

Press Ctrl + X to boot into single user mode. The system will stop at the initramfs prompt.

Boot into Single User Mode

Remount the system's root directory as read/write using the command: mount -o remount,rw /sysroot

Remount the Filesystem

Change root to access the system using the command: chroot /sysroot

Access the System

Use the command passwd to reset the root password. Enter the new password when prompted.

Change the Root Password

Type touch /.autorelabel to relabel SELinux contexts, exit the shell, and reboot the system using reboot.

Exit and Reboot