Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Recover the Root Password in RHEL 7

News

Booting into Rescue Mode

Recommended Links Grub Boot Directly into a Shell Runlevels mount command Serial console
Troubleshooting Errors in /etc/fstab Mounting partitions with chroot Linux root password recovery /etc/inittab /etc/fstab/ Filesystem mount options Reverting permissions in etc to redhat defaults Mounting Linux filesystems

Sudo

YaST

YaST System Repair

Resetting root password on MySQL Minimalistic and Rescue Linux Distributions

Knoppix Linux

Humor Etc

If you boot a RHEL 7 system into the rescue or emergency target, you are prompted for the root password. But what if you have forgotten the password? This exercise shows the steps required to reset a lost password for the root user. During the password-recovery process, you probably won’t have access to documentation. Hence, you should practice the following procedure until you can use it in a crisis:

  1. Reboot the server.
  2. When you see the following message, press a key to access the GRUB menu:
  3.  Press E to edit the current menu entry.
  4. Scroll down with the DOWN ARROW key to locate the line starting with linux16. Press CTRL-E or END to move to the end of the line, and then type the string rd.break.
  5. Press CTRL-X to boot the system.
  6. The rd.break directive interrupts the boot sequence before the root filesystem is properly mounted. Confirm this by running ls /sysroot. If you know the contents of the root filesystem, the output should look familiar.
  7. Remount the root /sysroot filesystem as read-write and change the root directory to /sysroot:

10.  Change the root password:

11.  Because SELinux is not running, the passwd command does not preserve the context of the /etc/passwd file. To ensure that the /etc/passwd file is labeled with the correct SELinux context, instruct Linux to relabel all files at the next boot with the following command:

touch /.autorelabel 

12.  Type exit to close the chroot jail, and then type exit again to reboot the system.

13.  It may take a few minutes for SELinux to relabel all files. Once you get a login prompt, confirm that you are able to log in as the root user.