TechBuzzPro

Boot into Single User Mode in CentOS

· 7 min read · Apps & Browsers

In this article
  1. What Single User Mode Is and When You Need It
  2. How to Boot into Single User Mode (GRUB 2, CentOS 7/8)
  3. Using systemd's Rescue Target (CentOS 7/8)
  4. How to Reset a Forgotten Root Password
  5. Common Problems and Troubleshooting
  6. Single User Mode vs. Other Recovery Methods
  7. Security Considerations
  8. Frequently Asked Questions

To boot into single user mode in CentOS, you interrupt the boot process at the GRUB menu and append single (or 1) to the kernel command line. This drops you into a root shell with minimal services, which is the standard way to recover from a forgotten root password, fix a misconfigured service, or repair filesystem issues.

What Single User Mode Is and When You Need It

Single user mode is a minimal Linux environment that runs only the most essential processes. Instead of starting the full multi-user system with networking, graphical interfaces, and background services, the kernel launches a root shell directly. This mode is part of the SysV init system, which CentOS 6 and earlier used, and it is still supported in CentOS 7 and 8 through systemd's rescue.target.

You typically need single user mode when the system will not boot normally. Common scenarios include:

  • You forgot the root password and need to reset it.
  • A misconfigured service (like a firewall or network manager) hangs during boot.
  • A filesystem check fails or a partition will not mount cleanly.
  • You need to repair a corrupted /etc/fstab or other critical configuration file.
  • You want to perform maintenance that requires no other users or services to be active.

Because it bypasses normal authentication, single user mode is a powerful recovery tool, but it also means anyone with physical access to the machine can gain root access. That is why it is usually disabled or password-protected on production servers.

How to Boot into Single User Mode (GRUB 2, CentOS 7/8)

CentOS 7 and later use GRUB 2. The process is straightforward but requires timing and careful keystrokes. Here are the steps:

  1. Reboot or power on the machine.
  2. When the GRUB menu appears, press e to edit the selected entry. If the menu is hidden, hold Shift (BIOS) or press Esc repeatedly (UEFI) to show it.
  3. Find the line that starts with linux (or linux16 on older installs). It contains kernel parameters like rhgb quiet.
  4. Use the arrow keys to move to the end of that line. Add a space and then type single or 1. For example: linux /vmlinuz-3.10.0-957.el7.x86_64 root=/dev/mapper/cl-root ro rhgb quiet single
  5. Press Ctrl+X or F10 to boot with the modified parameters.
  6. The system will start a minimal environment and present a root shell prompt (#).

If you are using CentOS 6 or earlier with GRUB 1, the process is similar: press e at the GRUB menu, select the kernel line, press e again, append single, then press b to boot.

Using systemd's Rescue Target (CentOS 7/8)

On CentOS 7 and 8, single user mode is implemented as rescue.target. When you append single to the kernel command line, systemd automatically starts this target. You can also reach it from a running system with the command:

systemctl rescue

This command shuts down all services and drops you into a rescue shell. It is equivalent to single user mode but uses systemd's structure. If you need to exit and return to normal multi-user mode, type exit or Ctrl+D at the rescue shell.

There is also emergency.target, which is even more minimal. It mounts the root filesystem read-only and gives you a shell before most system initialization. You can boot into it by appending emergency to the kernel command line instead of single.

How to Reset a Forgotten Root Password

One of the most common reasons to enter single user mode is to reset the root password. Once you have the root shell, the process is simple:

  1. Remount the root filesystem as read-write if it is not already. On CentOS 7/8, it is usually mounted read-only in rescue mode. Run: mount -o remount,rw /
  2. Type passwd root and press Enter.
  3. Enter a new password twice when prompted.
  4. Type exit or Ctrl+D to continue booting, or run reboot to restart.

On CentOS 7/8, the root filesystem is often mounted read-only by default in rescue mode, so the remount step is essential. If you skip it, you will see an error when trying to write the new password.

Common Problems and Troubleshooting

Several issues can arise when attempting to boot into single user mode:

  • GRUB menu does not appear. If the menu is hidden, try holding Shift (for BIOS) or pressing Esc (for UEFI) immediately after the firmware screen. On some systems, you may need to press a key repeatedly.
  • You see a login prompt instead of a shell. This can happen if SELinux is enforcing and the mode is restricted. In that case, boot with single enforcing=0 to temporarily disable SELinux, or use rd.break to break into an even earlier shell.
  • The root filesystem is read-only. As mentioned, remount it with mount -o remount,rw / before making changes.
  • Networking is not available. Single user mode does not start network services by default. If you need network access, you can start it manually with systemctl start network (CentOS 7) or nmcli networking on (CentOS 8).
  • You cannot type special characters. The keyboard layout may be different in rescue mode. Use the standard US layout unless you have configured otherwise.

If the system still fails to boot after your changes, double-check that you did not accidentally remove necessary kernel parameters. The root= parameter is critical; if it is missing, the system will not find its root filesystem.

Single User Mode vs. Other Recovery Methods

Single user mode is not the only recovery option. Understanding the differences helps you choose the right approach:

  • Single user mode / rescue.target: Minimal system with root shell, root filesystem mounted (read-only by default on systemd). Good for password resets and config fixes.
  • Emergency mode (emergency.target): Even more minimal, mounts only the root filesystem read-only. Useful when the system cannot even start basic services.
  • GRUB command line: You can boot a kernel manually from the GRUB prompt. This is useful if the boot entries are corrupted.
  • Live CD / Rescue disk: Boot from an external medium and mount the installed system. This is the best option when the boot loader itself is broken or the root filesystem is severely damaged.
  • rd.break (systemd): Breaks the initramfs before the real root is mounted, giving you a shell in the initramfs. You can use it to reset the root password by mounting the real root under /sysroot.

For a forgotten root password, single user mode is usually the quickest. For a completely unbootable system, a live CD is more reliable.

Security Considerations

Single user mode grants root access without a password, which is a significant security risk. On a server with physical access, anyone can reboot and enter single user mode to take over the system. To mitigate this, you can password-protect the GRUB editor and the single user mode entry.

To set a GRUB password on CentOS 7/8, you use the grub2-setpassword command. This creates a /boot/grub2/user.cfg file that requires a password to edit entries or boot into single user mode. The password is stored as a PBKDF2 hash, which is reasonably secure. On CentOS 6, you can add a password to /etc/grub.conf with the md5crypt command.

Another layer of protection is to set a password for single user mode itself. In /etc/sysconfig/init (CentOS 6) or via a systemd drop-in (CentOS 7/8), you can require a password before the rescue shell starts. However, this is rarely used because it complicates recovery.

Frequently Asked Questions

Can I enter single user mode without a physical console?

Yes, if you have out-of-band management like IPMI, iLO, or iDRAC, you can use the virtual console to interact with the GRUB menu and boot into single user mode. You can also use a serial console if it is configured. Without any remote console, you cannot do it over SSH because SSH is not running in single user mode.

What is the difference between single and 1 as kernel parameters?

There is no practical difference. The kernel treats 1 as an alias for single. Both tell init or systemd to start in single user mode. Some documentation uses s or S, but single is the most explicit and widely recommended.

Why is the root filesystem mounted read-only in single user mode?

This is a safety measure to prevent accidental corruption. The system assumes you are in recovery mode and wants to avoid writes until you explicitly allow them. You can remount it as read-write with mount -o remount,rw / when you are ready to make changes.

Can I boot into single user mode if I have encrypted the root filesystem?

Yes, but you will be prompted for the LUKS passphrase before the rescue shell appears. The initramfs handles the decryption, and then you enter single user mode. You need to know the passphrase; otherwise, you cannot proceed.

Does single user mode work on CentOS Stream or RHEL?

Yes, the process is identical because CentOS Stream and RHEL use the same GRUB and systemd. The commands and steps in this article apply to all of these distributions. The only difference may be the exact kernel version or default boot entry name.

How do I exit single user mode and return to normal boot?

Type exit or press Ctrl+D at the shell prompt. If you are using systemd, this will continue the boot process and start all normal services. If you want to reboot instead, type reboot or systemctl reboot.