centos8centos8

Single user mode is the maintenance or emergency mode where Linux geeks perform all troubleshooting steps. In Single user mode all the system services are stopped and only root user is allowed to execute commands. In this article we will demonstrate on how to boot CentOS 8 / RHEL 8 server into a single user mode and perform troubleshooting steps.

There are two ways to boot CentOS 8 and RHEL 8 server in Single User Mode

Method 1) Using “rd.break” keyword

Step:1) Reboot Your CentOS 8 or RHEL 8 Server and go to grub boot loader screen by interrupting auto boot and choose first line which includes the kernel (In case you have multiple kernel lines choose the appropriate one which suits to your environment). Below is the CentOS 8 boot loader screen,

Step:2) Press ‘e’ to enter in the edit mode and then go to the end of line which starts with ‘linux‘ word, type the keyword “rd.break

now press Ctrl-x to boot system in single user mode then we will get below screen,

Step:3) Remount the /sysroot in read-write (rw) mode

Run the following commands to mount sysroot file system in rw,

switch_root:/# mount -o remount,rw /sysroot
switch_root:/# chroot /sysroot
sh-4.4#

As we can see above that we got ‘sh’ shell prompt, now root user can execute the commands.

Let’s assume we want to recover root password by resetting it, so execute following commands one after the another

sh-4.4# echo “P@ssW0rD@123#” | passwd --stdin root 
sh-4.4# touch /.autorelabel

Once you are done with password reset, run below command to reboot your system

sh-4.4# reboot -f

Method 2) Replacing the ‘ro’ word with “rw init=/sysroot/bin/sh”

Step 1) Reboot your CentOS 8 / RHEL 8 System and interrupt the auto boot by entering up and down arrow key then we will get following grub screen.

Choose the first line which includes the kernel,

Step 2) Press ‘e’ to enter in edit mode and look for the line which starts with ‘linux’ word, replace the “ro” with “rw init=/sysroot/bin/sh

press “Ctrl-x” to boot the system in single user mode,

Step 3) Mount the root file system using chroot command,

:/# chroot /sysroot

Once you are done with changes and troubleshooting steps then reboot your system using following command,

:/# reboot -f