In some scenarios, you may need to use GNU GRand Unified Bootloader (GRUB) to enter the single-user mode for operations like troubleshooting startup errors, configuring disk partitions, and changing the boot user password. In single-user mode, the system loads only basic components and services. You have the permissions of system administrators, which allow you to modify all system configurations to perform troubleshooting. This topic describes how to boot an ECS instance that runs Alibaba Cloud Linux, Debian, SUSE Linux Enterprise Server (SLES), or Ubuntu into single user mode.
In single-user mode, critical configurations of the system can be modified, and misconfiguration may have severe impact on the system. Proceed with caution.
Procedure
The procedure for entering single-user mode varies across operating systems.
Alibaba Cloud Linux
In this example, an ECS instance that runs Alibaba Cloud Linux 3.2104 LTS 64-bit is used.
Connect to the instance.
For more information, see Connect to an instance by using VNC
NoteIf you connect to an instance by using Workbench or SSH commands, you are not redirected to the system boot page when you restart the instance by using a command. Therefore, we recommend that you do not connect to an instance by using Workbench or SSH commands.
Run the
reboot
command to restart the ECS instance and press e on the keyboard when the kernel selection screen appears.Move the cursor to the line that starts with
linux
and replace the content starting fromro
withrw init=/bin/sh crashkernel=auto
.Press Ctrl+X or F10.
The system boots into single-user mode.
Debian
In this example, an ECS instance that runs Debian 12.2 64-bit is used.
Connect to the instance.
For more information, see Connect to an instance by using VNC
NoteIf you connect to an instance by using Workbench or SSH commands, you are not redirected to the system boot page when you restart the instance by using a command. Therefore, we recommend that you do not connect to an instance by using Workbench or SSH commands.
Run the
reboot
command to restart the ECS instance and press e on the keyboard when the kernel selection screen appears.Move the cursor down to the line that starts with
linux
and addsingle
to the end of the line.Press Ctrl+X or F10 to start the system. Enter the password of the root user.
The system boots into single-user mode.
SLES
In this example, an ECS instance that runs SLES 15 SP1 64-bit is used.
Connect to the instance.
For more information, see Connect to an instance by using VNC
NoteIf you connect to an instance by using Workbench or SSH commands, you are not redirected to the system boot page when you restart the instance by using a command. Therefore, we recommend that you do not connect to an instance by using Workbench or SSH commands.
Run the
reboot
command to restart the ECS instance and press e on the keyboard when the kernel selection screen appears.Move the cursor down to the line that starts with
linux
and addsingle
to the end of the line.Press Ctrl+X or F10 to start the system. Enter the password of the root user.
The system boots into single-user mode.
Ubuntu
In this example, an ECS instance that runs Ubuntu 18.04 64-bit is used.
Connect to the instance.
For more information, see Connect to an instance by using VNC
NoteIf you connect to an instance by using Workbench or SSH commands, you are not redirected to the system boot page when you restart the instance by using a command. Therefore, we recommend that you do not connect to an instance by using Workbench or SSH commands.
Run the
reboot
command to restart the ECS instance and long press the Shift key during the restart until the GRUB interface appears.Use the arrow key to select Advanced options for Ubuntu and then press Enter.
Select recovery mode on the second line and press e on the keyboard.
On the new screen, move the cursor to the line that starts with
linux
and replace the content starting fromro
withrw single init=/bin/bash
.Press Ctrl+X or F10.
The system boots into single-user mode.
What to do next
In scenarios such as when the root password is locked, you can run the
passwd
command when in single-user mode to change the password.NoteIf the root password is not locked, you can change the password on the ECS console, without the need to use GRUB. For more information, see Reset the logon password of an instance.
You can use the single-user mode to perform troubleshooting operations, such as viewing the system logs, checking the service status, and testing network connections. For example, if you plan to use the single-user mode to troubleshoot a system startup failure, you can do the following:
If the startup failure is caused by issues in the system configuration file, you can modify the file.
If the startup failure is caused by issues in a driver or software package, you can uninstall them.
NoteYou can also perform troubleshooting by detaching the system disk. For more information, see Detach or attach a system disk.