How to Boot into Single User Mode in CentOS/RHEL 8

Single User Mode (sometimes known as Maintenance Mode) is a mode in Unix-like operating systems such as Linux operate, where a handful of services are started at system boot for basic functionality to enable a single superuser perform certain critical tasks.
In single-user mode, the services won’t start, and none of the users are allowed to log in except root. Also, the system would not prompt for login, which means you do not need a password to get root access.

In this tutorial, we will describe how to boot into single user mode on CentOS 8 / RHEL 8. Note that practically this will help you enter the emergency mode and access an emergency shell.

How to Boot into Single User Mode

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,

CentOS 8 grub menu

To go into single-user mode, select the kernel and press e edit arguments of the kernel.

Now, you should see the information about the selected operating system like hard disk, root partition, location of the kernel, crash kernel, and initrd (Initial ram disk).

Go to the line that starts with linux using up and down arrow then delete the ro argument.

Edit Grub Boot Options

Add this rw init=/sysroot/bin/sh in the line. Once done, press Ctrl+x.

Boot into Single-User Mode

Now, mount root file system with chroot command.

chroot /sysroot

Now, single-user mode is completely ready for use. Once you have fixed your problem to exit single user mode, perform the following steps.

CentOS/RHEL 7/8 uses SELinux by default, so create the following hidden file, which will automatically perform a relabel of all files on next boot.
# touch /.autorelabel

Finally, run the below command to restart the system. Alternatively, type “exit” command twice to restart your system.

# reboot -f

Conclusion

That’s all. You have learned how to boot into a single-user mode in CentOS 8 / RHEL 8. Please share your feedback in the comments section.

Exit mobile version