All Products
Search
Document Center

Elastic Compute Service:Boot a Linux or FreeBSD ECS instance into single-user mode

Last Updated:Mar 14, 2025

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.

Important

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.

  1. Connect to the instance.

    For more information, see Connect to an instance by using VNC

    Note

    If 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.

  2. Run the reboot command to restart the ECS instance and press e on the keyboard when the kernel selection screen appears.

    内核选项界面.png

  3. Move the cursor to the line that starts with linux and replace the content starting from ro with rw init=/bin/sh crashkernel=auto.

    进入单用户模式.png

  4. Press Ctrl+X or the F10 key.

    The system boots into single-user mode.

    alibaba进入单用户模式.png

CentOS

In this example, an ECS instance that runs CentOS 7 64-bit is used.

  1. Connect to the instance.

    For more information, see Connect to an instance by using VNC

    Note

    If 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.

  2. 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.

    image

  3. 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.

    image

  4. 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.

    image

Debian

In this example, an ECS instance that runs Debian 12.2 64-bit is used.

  1. Connect to the instance.

    For more information, see Connect to an instance by using VNC

    Note

    If 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.

  2. Run the reboot command to restart the ECS instance and press e on the keyboard when the kernel selection screen appears.

    db1

  3. Move the cursor down to the line that starts with linux and add single to the end of the line.

    db3

  4. 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.db4

SUSE Linux Enterprise Server

In this example, an ECS instance that runs SUSE Linux Enterprise Server 15 SP1 64-bit is used.

  1. Connect to the instance.

    For more information, see Connect to an instance by using VNC

    Note

    If 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.

  2. Run the reboot command to restart the ECS instance and press e on the keyboard when the kernel selection screen appears.

    sles1

  3. Move the cursor down to the line that starts with linux and add single to the end of the line.

    sles2

  4. 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.sles3

Ubuntu

In this example, an ECS instance that runs Ubuntu 18.04 64-bit is used.

  1. Connect to the instance.

    For more information, see Connect to an instance by using VNC

    Note

    If 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.

  2. Run the reboot command to restart the ECS instance and long press the Shift key during the restart until the GRUB screen appears.

    ubt1

  3. Use the arrow key to select Advanced options for Ubuntu and then press the Enter key.

  4. Select recovery mode on the second line and press e on the keyboard.

    ubt2

  5. On the new screen, move the cursor to the line that starts with linux and replace the content starting from ro with rw single init=/bin/bash.

    ubt4

  6. Press Ctrl+X or the F10 key.

    The system boots into single-user mode.ubt5

FreeBSD

In this example, an ECS instance that runs FreeBSD 14.1 64-bit is used.

  1. Connect to the instance.

    For more information, see Connect to an instance by using VNC.

    Note
    • If 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.

  2. 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.

    Note

    If 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.

    image

    The following figure shows that the Cons output mode is changed to Video primary.

    image

  3. Press 2 to select Boot Single User.

    image

  4. The system loads and enters the CLI in single-user mode. You can perform other operations based on your business requirements.

    image

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.

    Note

    If 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.

    Note

    You can also perform troubleshooting by detaching the system disk. For more information, see Detach or attach a system disk.