How to Boot RHEL 7 / CentOS 7 Server in Single User Mode

For Linux system admins, booting RHEL 7 / CentOS 7 servers in single user mode is the most common day to day activities. Single user mode is considered as maintenance or emergency mode where we can perform our troubleshooting steps. Following are the scenarios where we need to boot our RHEL / CentOS Servers in Single user mode:

  • Reset Root password – There can be some scenarios where someone from the team has reset the root password and he/she didn’t share it with team and left the organization
  • Repairing file system – There are some situations where OS(operating system) file systems got corrupted and while rebooting server didn’t come up, so in that case we have to repair file system by entering into single user mode.
  • Fix Wrong entry of fstab file – Let’s suppose I have created one file system on RHEL / CentOS Server and update the /etc/fstab file, but there was some typo while updating the file system entries. I got the request to reboot the server, so while booting up it got stuck while mounting that file system. So to resolve and fix such issue, we need to boot Linux servers in Single User mode.
  • Disabling / enabling Service – There can some service which is taking lot of time or delaying the boot. So in that case we can disable that service from single user mode. On the contrary we can also enable specific service from single user mode.

There are two methods through which we can boot CentOS 7 / RHEL 7 servers in Single User Mode.

Method 1:

Step1: Reboot your Server and go to Grub boot loader menu and choose the appropriate kernel, example is shown below:

RHEL-7-Grub-Menu-screen

Step 2: Press ‘e’ and go to the end of line which starts with ‘linux16’ word.

Grub-Menu-Linux16-RHEL7

Type “rd.break” at end of line which begins with linux16 and then press “ctrl+x

rd-break-grub-menu-rhel7

In the next window we will get single user mode or emergency mode, something like below:

emergency-mode-rhel7

Step 3: Now remount the /sysroot in ‘rw’ mode

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

Let’s assume we want to reset root password. Run the beneath commands

sh-4.2# echo “New-root-password” | passwd --stdin root
sh-4.2# touch /.autorelabel

Reset-Root-Password-RHEL7-single-User-Mode

Now you can edit the files and scan  corrupted file system with fsck command. Once you are done with troubleshooting Type ‘exit‘ command two times or ‘reboot -f‘ to reboot your server.

Method 2:

Step 1: Reboot the server and go to the grub menu and select the appropriate kernel

Grub-Menu-CentOS7

Step 2: Press ‘e’ and go the line with starts with ‘linux16’

Replace “ro” with “rw init=/sysroot/bin/sh

replace-ro-with-rw-init-sysroot-centos7

Once done with the changes press ‘Ctrl+x’

emergency-mode-CentOS7

Step 3: Mount the root file system with chroot command

:/# chroot /sysroot

Let’s assume I want to disable network manager service and rest root password, run the following commands:

:/# systemctl disable NetworkManager
:/# echo “Enter-New-Root-password” | passwd --stdin root
:/# touch /.autorelabel

Once you are done with the changes, type “reboot -f” command to reboot your server

reset-root-password-disable-service-single-user-mode-centos7

Note: In production environment, Single user mode is also password protected. By default root password is the single user mode password on CentOS 7 / RHEL 7 Servers.

That’s all from this tutorial. In case these steps help to resolve any technical issue then please do share your comments in the comments section below.

5 thoughts on “How to Boot RHEL 7 / CentOS 7 Server in Single User Mode”

    1. Hi Steven,

      No, above mentioned steps are not applicable for CentOS 6 or RHEL 6 servers.

      Please refer the following steps to boot CentOS 6 / RHEL 6 Server in Single User mode:

      1) Reboot the server, Go to Grub menu and select the kernel
      2) Press ‘e’ and go to the end of line which starts with Kernel and type ‘1’ or single.
      3) Then type ‘b’ to boot your server in single or maintenance mode.
      4) Now perform your troubleshooting steps like reset the password, scanning and disabling specific service etc.
      5) Reboot the server after doing troubleshooting.

  1. Absolutely invaluable information! Love these tutorials!….This helped me get back into a CEntOS server that I thought I was going to have to rebuild! Nice work…thanks so much!!

  2. Thank you for posting this! This saved me a whole lot of headaches! I would note to let the others out there know that you can access the entire root file system by following the methods listed above. I spent an hour trying stuff before I discovered this page. I added it to my favorites! I owe you a beer!

Leave a Comment

Your email address will not be published. Required fields are marked *