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

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.

It is runlevel 1 under system SysV init, and runlevel1.target or rescue.target in systemd. Importantly, the services, if any, started at this runlevel/target varies by distribution. It’s generally useful for maintenance or emergency repairs (since it doesn’t offer any network services at all), when a computer is not capable of normal operations.

Some of the low-level repairs include running such as fsck of damaged disk partitions, reset root password if you have lost it, fix “failed to mount /etc/fstab” error – just to mention the most critical of them. And also when the system fails to boot normally.

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

How to Boot into Single User Mode

1. First restart your CentOS 7 machine, once boot process starts, wait for the GRUB boot menu to appear as shown in the screen shot below.

CentOS 7 Grub Menu
CentOS 7 Grub Menu

2. Next, select your Kernel version from the grub menu item and press e key to edit the first boot option. Now use the Down arrow key to find the kernel line (starts with “linux16“), then change the argument ro to rw init=/sysroot/bin/sh as shown in the screen shot below.

Edit Grub Boot Options
Edit Grub Boot Options

3. Once you have finished the task in the previous step, press Ctrl-X or F10 to boot into single user mode (access an emergency shell).

CentOS 7 Emergency Shell
CentOS 7 Emergency Shell

4. Now mount root (/) filesystem using the following command.

# chroot /sysroot/

At this point, you can perform all the necessary low-level system maintenance tasks. Once you are done, reboot the system using this command.

# reboot -f

You may also liked to read following articles.

  1. How to Hack Your Own Linux System
  2. Linux Directory Structure and Important Files Paths Explained
  3. How to Create and Run New Service Units in Systemd Using Shell Script
  4. How to Manage ‘Systemd’ Services and Units Using ‘Systemctl’ in Linux

Lastly, the single user mode or maintenance mode is not password-protected by default, so any one with malicious intend and physical access to your computer can enter the emergency mode and “destroy” your system.

Next, we will show you how to password-protect single user mode on CentOS 7. Until then, stay connected to Tecmint.com.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

20 Comments

Leave a Reply
  1. I can’t run any commands when in single-user mode – My server just dropped to maintenance mode after the backup drive needed an fsck – but after it dropped to shell – any command I type such as fsck results in “no such file or directory”. Help! I need to either mount the filesystem to edit /etc/fstab and remove the second drive – or run fsck on it – but neither command is found!

    Reply
  2. How to start the networking in RHEL 7 on single user mode?

    Errror:
    systemctl start network
    Failed to get D-Bus Connection: Operation not permitted
    
    Reply
    • @Raj,

      In single user mode on RHEL 7 or CentOS 7, the networking not enabled at startup. To get networking, you need get into runlevel 2 (local multi-user with networking) by running following command.

      # telinit 2
      
      Reply
    • @João

      Sure, we will prepare an article about how to password-protect single user mode on CentOS 7. Thanks for the feedback.

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.