
For virtually any software tool, administrators must make considerations of particular modes. Single User Mode in CentOS 7 is one such mode that provides Single User Mode troubleshooting capabilities. Administrators can do maintenance tasks, reset root passwords, or resolve critical damage problems. In case you need to access a problematic system or deal with booting troubles, this text will demonstrate how to utilize Single User Mode (Rescue Mode) step by step.
In this detailed guide, I’ll walk you through:
- What Single User Mode is and when to use it
- How to boot into Single User Mode step by step
- Common issues and how to fix them
- Security risks and best practices
What is Single User Mode in CentOS 7?
Single User Mode, also known as Rescue Mode, is a minimal Linux environment where only the root user has access. The system runs with essential services only, without networking, making it ideal for troubleshooting and performing system repairs.
It is mainly used for:
- Resetting lost root passwords
- Fixing boot errors
- Repairing file system issues
- Disabling faulty services
Unlike multi-user mode, where multiple users and network services are active, single user mode gives exclusive access to the root user with minimal interference.
When Should You Use Single User Mode?
You should boot into Single User Mode in CentOS 7 when:
- Forgot the root password and need to reset it.
- System fails to boot due to a corrupted file system or misconfiguration.
- Need to disable a malfunctioning service preventing normal boot.
- Suspect a security breach and need to investigate.
It is a powerful but also high-risk mode—anyone with physical access to your machine can modify critical system files, so use it cautiously.
Prerequisites Before Entering Single User Mode
Before proceeding, ensure:
- You have physical or console access to the CentOS 7 system (remote access won’t work).
- The GRUB bootloader is accessible (not password-protected).
- You have a basic understanding of Linux commands (we’ll guide you step-by-step).
If your GRUB menu is password-protected, you must know the GRUB password to enter Single User Mode.
How to Boot into Single User Mode in CentOS 7
Follow these steps to enter Single User Mode in CentOS 7:
Step 1: Restart Your System
Reboot your CentOS 7 system by running:
bash
sudo reboot
Or manually restart it if you don’t have terminal access.
Step 2: Access the GRUB Menu
1️⃣ As soon as the system starts rebooting, press the ESC
key repeatedly to stop the automatic boot process.
2️⃣ You should see the GRUB bootloader menu.
If you don’t see the GRUB menu, try holding down Shift while the system boots.
Step 3: Edit the Boot Entry for Single User Mode
1️⃣ Use the arrow keys to highlight the default kernel (usually the first option).
2️⃣ Press e
to edit the selected boot entry.
This opens the GRUB configuration for the selected kernel.
Step 4: Modify the Boot Parameters
1️⃣ Locate the line starting with linux16
.
2️⃣ At the end of this line, replace “ro” with “rw init=/sysroot/bin/sh”
Your edited line should look like this:
bash
linux16 /vmlinuz-3.10.0-xxx.x.el7.x86_64 root=/dev/mapper/centos-root rw init=/sysroot/bin/sh
Step 5: Boot into Single User Mode
Press Ctrl + X
to boot the system with the modified parameters.
Congratulations! You are now in Single User Mode. You will see a command prompt like:
bash
sh-4.2#
From here, you can reset passwords, fix file system issues, and perform other maintenance tasks.
Resetting Root Password in Single User Mode
If you need to reset the root password, follow these steps:
Step 1: Access the Root Filesystem
Run the following command to access the system properly:
bash
chroot /sysroot
Now, your prompt should change to:
bash
sh-4.2#
Step 2: Reset the Root Password
Run:
bash
passwd root
It will prompt you to enter a new root password.
Important: Ensure your new password is strong (mix of uppercase, lowercase, numbers, and symbols).
Step 3: Update SELinux Context
If SELinux is enabled, update the security context:
bash
touch /.autorelabel
Step 4: Exit and Reboot
Exit the chroot environment:
bash
exit
Then reboot the system:
bash
reboot -f
Your new root password is now active.
Exiting Single User Mode and Rebooting
Once you’re done troubleshooting, exit Single User Mode with:
bash
reboot
Your system should now boot normally.
Common Issues and Troubleshooting Tips
🔹 Issue: GRUB Menu Not Showing
👉 Hold Shift or press ESC repeatedly during boot.
🔹 Issue: Cannot Edit GRUB Entry
👉 Ensure the GRUB menu is not password-protected.
🔹 Issue: Password Reset Not Working
👉 Make sure to run chroot /sysroot
before changing the password.
Security Risks of Single User Mode
🚨 Single User Mode Bypasses System Security 🚨
- No login required – Anyone with physical access can modify your system.
- Critical system changes – Misconfiguration can break your system.
- Solution – Protect your GRUB menu with a password:
bash
grub2-setpassword
Conclusion
Booting into Single User Mode in CentOS 7 is a powerful troubleshooting tool that lets you reset passwords, fix boot issues, and repair file systems. However, it also poses security risks, so it should be used carefully and secured with a GRUB password.
If you follow this step-by-step guide, you’ll be able to fix most boot-related issues in CentOS 7 effortlessly.
FAQs
1. What is Single User Mode used for in CentOS 7?
It is used for troubleshooting, password resets, and fixing boot issues.
2. Can I enable networking in Single User Mode?
By default, networking is disabled, but you can start it manually using:
bash
systemctl start network
3. What if I forgot my GRUB password?
You will need to boot from a CentOS installation disk and manually reset it.
4. How do I disable Single User Mode?
Protect it by setting a GRUB password using:
bash
grub2-setpassword
5. What happens if I modify GRUB incorrectly?
You may break the boot process. Always double-check changes before rebooting.
6. Can I access Single User Mode remotely via SSH?
No, Single User Mode is a local-only mode because networking services are disabled. You must have physical or console access to the system.
7. What is the difference between Single User Mode and Emergency Mode in CentOS 7?
Feature | Single User Mode | Emergency Mode |
---|---|---|
Purpose | Troubleshooting, password resets, fixing services | Fixing critical system failures (corrupt filesystems, broken bootloader) |
Root Filesystem | Mounted as read/write | Mounted as read-only |
Services Running | Minimal services | No services running |
Networking | Disabled by default | Disabled |
Emergency Mode is used when the system fails to boot entirely, while Single User Mode is more for administrative recovery tasks.
8. What if I cannot edit the GRUB boot parameters?
This usually happens when GRUB is password-protected. If you don’t know the password, you will need to:
- Boot from a CentOS 7 Live CD or USB
- Mount your root filesystem
- Edit
/etc/grub.d/00_header
or/boot/grub2/grub.cfg
to reset or remove the GRUB password
9. How do I enable networking in Single User Mode?
By default, networking is disabled. To enable it, run:
bash
systemctl start network
Or, for NetworkManager-based setups:
bash
systemctl start NetworkManager
10. Can I create a new user while in Single User Mode?
Yes, you can create a new user with:
bash
useradd newuser
passwd newuser
However, this user won’t have sudo privileges unless you modify /etc/sudoers
to grant access.
11. How do I manually check and repair the filesystem in Single User Mode?
If you suspect filesystem corruption, run:
bash
fsck -y /dev/mapper/centos-root
or
bash
fsck -y /dev/sda1
Replace /dev/sda1
with your actual partition.
12. How do I mount additional partitions in Single User Mode?
To mount other partitions manually, use:
bashmount /dev/sdX /mnt
Replace /dev/sdX
with your actual partition identifier.
13. How do I check system logs for troubleshooting in Single User Mode?
You can view logs using:
bash
journalctl -xb
Or check specific logs:
bash
cat /var/log/messages
bash
cat /var/log/dmesg
14. What happens if I forget to update SELinux context after resetting the root password?
If SELinux is enabled, you may not be able to log in after reboot. To prevent this, always run:
bash
touch /.autorelabel
before rebooting.
15. Can I disable SELinux from Single User Mode?
Yes, edit the SELinux config file:
bash
vi /etc/selinux/config
Change:
plaintext
SELINUX=enforcing
To:
plaintext
SELINUX=disabled
Then, reboot.
16. How do I permanently disable Single User Mode for security reasons?
You can protect Single User Mode by setting a GRUB password:
bash
grub2-setpassword
This prevents unauthorized users from modifying boot parameters.
17. How do I enable Single User Mode from the GRUB command line (if the menu is missing)?
If your GRUB menu doesn’t appear, manually enter the GRUB command line:
1. At the GRUB prompt, type:
bashset root=(hd0,1) linux16 /vmlinuz-3.10.0-xxx root=/dev/mapper/centos-root rw init=/sysroot/bin/sh initrd16 /initramfs-3.10.0-xxx.img
boot
2. Replace xxx
with your actual kernel version.
18. Can I boot into Single User Mode using a CentOS Installation Disk?
Yes, you can enter Rescue Mode using a CentOS 7 installation ISO:
- Boot from the CentOS 7 ISO
- Select Troubleshooting → Rescue a CentOS system
- Choose 1) Continue
- Mount the root filesystem with:
bashchroot /mnt/sysimage
19. How do I undo changes if I accidentally break my system in Single User Mode?
If your system fails to boot after making changes, try:
- Boot back into Single User Mode
- Undo any changes you made to critical files (
/etc/fstab
,/etc/selinux/config
, etc.) - If needed, restore from backups with:
bashcp /etc/fstab.backup /etc/fstab
20. Can I configure my CentOS 7 system to always boot into Single User Mode?
Yes, but be careful! Modify the GRUB configuration:
1. Edit /etc/default/grub
:
bashvi /etc/default/grub
2. Change the GRUB_CMDLINE_LINUX
line to:
plaintextGRUB_CMDLINE_LINUX="rw init=/sysroot/bin/sh"
3. Update GRUB:
bashgrub2-mkconfig -o /boot/grub2/grub.cfg
4. Reboot.