Like safe mode in Microsoft Windows, Linux has rescue or emergency mode for troubleshooting purposes. And here’s how to get into the mode in most Linux Distributions.
After configured Linux incorrectly, broke drivers or forgot user password, system may refuse to boot/login. If system boots into login screen, you may press Ctrl+Alt+F1 ~ F6 to switch TTY command console. Or, use the recovery or emergency mode to rescue. The rescue mode is a blank and white text console without graphical interface, which provides root (super user) privilege with full access to your file system. It can rescue but also destroy your Linux!
You need root password (if enabled) to get into recovery / emergency mode in most Linux, including Debian, Fedora, CentOS, etc. Though Ubuntu is somehow less secure, since anyone can access without authentication. If root NOT enabled, it will prompt "root account is locked" and try normal boot. In this case, an USB Linux installer is required to rescue.
Get into Recovery Mode in Debian / Ubuntu:
In Debian and Ubuntu based systems, recovery mode is present in boot-menu. Start or re-start your computer and press Esc (in some machines, press and hold Shift key) key to show the Grub boot-menu.
Then choose “Advanced options for …” from menu and boot the kernel entry with (recovery mode) in the end.
In Debian it will boot into text console and ask you typing root user password to get pass, or say ‘root account is locked‘ if root is not enabled. Type the password and hit Enter, then there you are!
For Ubuntu based systems, the ‘recovery mode’ entry will boot into the following screen. Choose ‘root – Drop to root shell prompt‘ and hit Enter.
Then hit Enter again will get into rescue mode with read-only access. Before get started troubleshooting, you need enable read & write permission by remounting the file system via command:
mount -o rw,remount /
NOTE: Some Ubuntu based systems, e.g., Zorin OS, may also require root password authentication to get access.
Boot into Emergency Mode in Fedora / CentOS:
For Fedora, CentOS and Arch Linux, there’s no recovery mode in the boot-menu. Instead, user need to edit the menu entry to boot with given parameters.
Start or re-start your computer and press Esc on keyboard to get into Grub boot-menu. When you’re there, press ‘e‘ on keyboard to edit the default entry as the bottom words indicate.
In next screen, use arrow keys to navigate to the end of the line with ‘linux’ in the beginning. It’s a long line separated into two or three via ‘\‘. At the end, input a blank space and then type ‘systemd.unit=emergency.target‘.
For choice, you may replace ‘systemd.unit=emergency.target‘ with a single ‘s‘ to do the same job, or use ‘3‘ to boot into TTY console.
For those forgot the root password, use init=/bin/bash will boot into the shell without authentication. Though mount -o rw,remount /
command is required to remount the file system.
After adding the new boot parameter, press Ctrl+X to boot the entry. It will bring you into the rescue mode, and ask for typing root password (no visual feedback) for maintenance. Once get pass the authentication, there you are!
As it indicates, run journalctl -xb
to check system log and see what went wrong, or reset password via passwd USER_NAME
. When everything’s done, use exit
command to go normal boot or systemctl reboot
to restart machine.
That’s all. Enjoy!
Recent Comments