In specific scenarios, you may need to enter the single-user mode for operations such as troubleshooting startup errors, handling system exceptions, configuring disk partitions, and changing the boot user password. In single-user mode, the system loads only basic components and services, and you have system administrator permissions, which allow you to modify all system configurations to perform troubleshooting. This topic describes how to boot an Elastic Compute Service (ECS) instance that runs an operating system such as Alibaba Cloud Linux, CentOS, or FreeBSD 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 the F10 key.
The system boots into single-user mode.
CentOS
In this example, an ECS instance that runs CentOS 7 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. Then, the GRand Unified Bootloader (GRUB) screen appears, as shown in the following figure.Move the cursor down to the line that starts with
linux
and add single to the end of the line.The following figure shows the configuration.
Press Ctrl+X or the F10 key to start the system and enter the password of the
root
user.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 the F10 key to start the system. Enter the password of the
root
user.The system boots into single-user mode.
SUSE Linux Enterprise Server
In this example, an ECS instance that runs SUSE Linux Enterprise Server 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 the F10 key 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 screen appears.Use the arrow key to select Advanced options for Ubuntu and then press the Enter key.
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 the F10 key.
The system boots into single-user mode.
FreeBSD
In this example, an ECS instance that runs FreeBSD 14.1 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.
FreeBSD 12.1 or later images do not support password-based logons. When you connect to an instance that runs FreeBSD 12.1 or later by using Virtual Network Computing (VNC), you remain on the page that requires you to enter a username and password on the VNC management terminal. For information about the compatibility of FreeBSD versions with Alibaba Cloud platforms, see Compatibility of the FreeBSD operating system.
Restart the ECS instance in the ECS console. During the restart process, press 5 to change the Cons output mode to Video primary when the boot menu appears on the VNC management terminal.
NoteIf you set the Cons output mode to Serial primary, you may be unable to view any output on the VNC management terminal, because interactive information between the instance and the ECS console is redirected to the serial port.
The following figure shows that the Cons output mode is changed to Video primary.
Press 2 to select Boot Single User.
The system loads and enters the CLI in single-user mode. You can perform other operations based on your business requirements.
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.