Boot CentOS/RHEL in single user mode
There are two ways to boot CentOS 8 and RHEL 8 server in Single User Mode
Method 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).
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 Press Ctrl-x to boot system in single user mode
Remount the /sysroot in read-write (rw) mode
switch_root:/# mount -o remount,rw /sysroot
switch_root:/# chroot /sysroot
sh-4.4#
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
Method 2
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).
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,
Mount the root file system using chroot command,
:/# chroot /sysroot
Let’s assume you want to correct some invalid entries in fstab file,
:/# vi /etc/fstab