TechBuzzPro

AlmaLinux Single User Mode: Boot & Recovery

· 6 min read · Apps & Browsers

In this article
  1. What Single User Mode Is and Why It Exists
  2. Entering Single User Mode on AlmaLinux (GRUB)
  3. What You Can Do in Single User Mode
  4. How to Choose Between Single User and Emergency Mode
  5. Common Problems and How to Fix Them
  6. Single User Mode vs. Recovery Tools on Other Distros
  7. Security and Safety Considerations
  8. Frequently Asked Questions

AlmaLinux single user mode is a minimal maintenance state that boots the system to a root shell without starting normal services, used for password recovery, filesystem repairs, and troubleshooting boot failures. You enter it by interrupting the boot process and adding single or 1 to the kernel command line. This guide explains exactly how to do that on AlmaLinux 8 and 9, what you can do once you are in, and how to get back to a normal boot.

What Single User Mode Is and Why It Exists

Single user mode (also called runlevel 1 or rescue.target on systemd systems) is a special boot target that starts the system with the minimum required to give you a root shell. It mounts the root filesystem (often read-only initially), loads essential kernel modules, and does not start network services, graphical interfaces, or multi-user login managers. It exists so an administrator can fix a system that will not boot normally: reset a forgotten root password, repair a corrupted /etc/fstab, check and repair filesystems, or remove a problematic package.

AlmaLinux uses systemd, so the traditional SysV runlevel 1 is mapped to rescue.target. When you boot into single user mode, systemd starts only the units required for rescue, giving you a root shell on the console. This is different from emergency.target, which mounts only the root filesystem read-only and does not start network or other local filesystems. For most recovery tasks, single user mode is sufficient.

Entering Single User Mode on AlmaLinux (GRUB)

To enter single user mode, you must interrupt the GRUB boot loader at startup. The steps are the same for AlmaLinux 8 and 9, and for both BIOS and UEFI systems:

  1. Restart or power on the machine.
  2. When the GRUB menu appears (usually after a few seconds), press e to edit the selected kernel entry. If the menu does not show, press Esc or hold Shift (BIOS) / Esc (UEFI) to force it.
  3. Find the line that starts with linux (or linuxefi on UEFI). It ends with rhgb quiet on AlmaLinux.
  4. Move the cursor to the end of that line, add a space, then type single or 1 (or s). You can also add systemd.unit=rescue.target for the same effect.
  5. Press Ctrl+X or F10 to boot with the modified parameters.

The system will boot into a root shell. If the root filesystem is mounted read-only, you can remount it read-write with mount -o remount,rw / before making changes.

What You Can Do in Single User Mode

Once you have the root shell, you have full root privileges. Common tasks include:

  • Resetting a forgotten root password: Run passwd root and set a new password.
  • Repairing filesystems: Run fsck /dev/sda1 (replace with the correct device) to check and repair errors. Make sure the partition is unmounted first.
  • Fixing /etc/fstab: If a bad entry prevents booting, edit the file with vi or nano and correct or comment out the problematic line.
  • Removing or disabling problematic services: Use systemctl disable to prevent a service from starting at boot.
  • Rolling back updates: If a recent kernel update broke booting, you can remove the new kernel package with dnf remove kernel- (though it is often easier to boot an older kernel from GRUB).

Remember that the system is not fully started, so many commands that depend on network or other services will not work. For example, dnf may fail if it needs network access; you can start networking manually with systemctl start network (or NetworkManager) if needed.

How to Choose Between Single User and Emergency Mode

AlmaLinux offers two rescue targets: rescue.target (single user) and emergency.target. The choice depends on what you need:

  • Single user mode (rescue.target): Starts more services, including local filesystems (except those marked noauto), and gives you a shell. Use this for most recovery tasks like password reset or filesystem repairs.
  • Emergency mode (emergency.target): Starts the absolute minimum, mounts only the root filesystem read-only, and gives a shell. Use this if the system cannot even start rescue.target due to a broken filesystem or a critical service.

To boot into emergency mode, add emergency or systemd.unit=emergency.target to the kernel command line instead of single.

Common Problems and How to Fix Them

Several issues can arise when trying to enter single user mode:

  • GRUB menu does not appear: On UEFI systems, the menu may be hidden. Press Esc repeatedly during boot. On some systems, you need to hold Shift (BIOS) or Esc (UEFI) immediately after the firmware screen.
  • Root filesystem is read-only: This is normal. Remount it with mount -o remount,rw / before making changes.
  • SELinux blocks access: If you change files in single user mode, SELinux contexts may be wrong. Run touch /.autorelabel before rebooting to force a relabel on next boot.
  • Network is not available: Start it manually with systemctl start NetworkManager or systemctl start network (depending on your setup).
  • Forgot to add single correctly: Make sure you add it to the linux line, not the initrd line. If you add it to the wrong line, the boot may fail.

Single User Mode vs. Recovery Tools on Other Distros

Single user mode on AlmaLinux is similar to that on CentOS, RHEL, and Fedora. On Ubuntu and Debian, you can also add single or recovery to the kernel command line, but the recovery mode is a menu option in GRUB. AlmaLinux does not have a separate recovery entry; you always edit the kernel line. The systemd target names (rescue.target and emergency.target) are standard across all systemd-based distributions, so the commands work the same on AlmaLinux, Fedora, and Ubuntu (if you use systemd).

Security and Safety Considerations

Single user mode gives anyone with physical access to the console full root access without a password. This is a security risk if the machine is in an untrusted location. To mitigate this, you can set a password for the GRUB boot loader, which will require a password to edit entries or boot into single user mode. You can also configure the kernel to require a password for single user mode by setting SULOGIN(8) or using a systemd service override, but the simplest is to password-protect GRUB. Additionally, always ensure you have a backup of important data before performing filesystem repairs, and be careful when editing configuration files—a mistake can make the system unbootable.

Frequently Asked Questions

How do I exit single user mode and boot normally?

Type exec /sbin/init or systemctl default to continue booting to the default target (multi-user or graphical). Alternatively, type reboot to restart the system and boot normally.

Can I enter single user mode without a password?

Yes, if GRUB is not password-protected, you can boot into single user mode and get a root shell without entering a password. This is why physical security is important. If GRUB has a password, you will be prompted for it before you can edit the kernel line.

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

It is a safety measure to prevent accidental damage. You can remount it read-write with mount -o remount,rw / when you are ready to make changes.

Can I use single user mode to reset another user's password?

Yes, you can. Once you have a root shell, run passwd to set a new password for any user.

What if I cannot edit the GRUB entry because the screen is blank?

Try pressing Esc repeatedly during boot to force the GRUB menu. If that does not work, you may need to use a live CD or rescue disk to repair the system.