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.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

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.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

16 Responses

  1. Irsyad says:

    Is it possible to edit /etc/sudoers in single user mode ? I need to edit the “PermitRootLogin” section.

  2. PM says:

    Very helpful article, enabled me to fix my login service

  3. gzcwnk says:

    touch /.autorelabel
    reboot

    is needed

  4. Raja says:

    This article helped in solving my issue today
    Thank you

  5. Rodolfo says:

    Works perfect, thanks I could recover my sudo access .. !!

  6. Raj says:

    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
    
    • Ravi Saive says:

      @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
      
  7. João Olavo Vasconcelos says:

    Nice! Could you show us how to password-protect single user mode on CentOS 7?

  8. Jean-Pierre says:

    Great, it’s very useful .Thanks for the work

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.