All Products
Search
Document Center

Elastic Compute Service:Install a GUI desktop on a Linux instance

Last Updated:Dec 17, 2024

If you want to visualize your operations, design graphics, process multimedia materials, or perform routine office tasks or you are unfamiliar with commands, you can use a GUI desktop. This significantly improves user experience and work efficiency. To ensure performance and versatility, GUI desktop components, including GNOME, KDE Plasma, MATE Desktop, and Ubuntu Desktop, are not pre-installed in public Linux images provided by Alibaba Cloud for Elastic Compute Service (ECS). This topic describes how to install a GUI desktop on ECS instances that run mainstream Linux operating systems and how to resolve installation issues.

Introduction to and basic components of a GUI desktop

What is a Linux GUI desktop?

In a Linux operating system, a GUI desktop is an interface that allows users to interact with the operating system by using graphical elements, such as windows, icons, buttons, and menus. A Linux GUI desktop is similar to a Windows GUI desktop. A GUI desktop is more intuitive and user-friendly than the traditional command-line interface (CLI) and is suitable for most routine operations.

Main components of a GUI desktop

  • Display server

    A display server is responsible for managing graphical display effects and input devices. Common display servers include Xorg, which is an implementation of the X11 protocol, and Wayland. The implementation of the X11 protocol is the basis of Linux graphical environments and is responsible for managing display effects, input devices such as keyboards and mouses, and window rendering. Wayland is a newer display protocol designed to replace the X11 protocol. Wayland provides higher efficiency, better security, and smoother graphics experience than X11. A number of modern desktop environments support Wayland.

  • Window manager

    A window manager is responsible for managing the appearances and behaviors of windows, such as the movement, resizing, and minimization of windows. A window manager can be standalone or integrated in the desktop environment.

  • Desktop environment

    A desktop environment is a collection of components, including the window manager, icons, toolbars, and system settings, that work together to provide consistent user experience. Common desktop environments include GNOME, KDE Plasma, Xfce, and LXDE.

  • Application framework and toolkit

    A GUI desktop contains a variety of application and system components, such as text editors, browsers, file managers, and multimedia players. The components together provide a complete graphical user experience.

Common desktop environments

  • GNOME

    GNOME is a modern, simplified, and user-centric desktop environment. GNOME uses the GTK toolkit and has an own set of applications, such as Nautilus File Manager and GNOME Terminal. GNOME focuses on consistency and ease of use and is suitable for beginners and users who want a simple interface. For more information, see GNOME.

  • KDE Plasma

    KDE Plasma is a feature-rich, highly customizable desktop environment based on the Qt toolkit. KDE Plasma provides a rich ecosystem of applications, such as Dolphin File Manager and Konsole Terminal. KDE Plasma is suitable for users who require a high degree of customization and rich functionality. For more information, see The KDE Plasma desktop.

  • Xfce

    Xfce is a lightweight, low-resource desktop environment suitable for old hardware or systems that require high performance. Xfce provides basic desktop functionality, supports the GTK toolkit, and balances performance and user experience. For more information, see Xfce Desktop.

  • LXDE and LXQt

    LXDE and LXQt are lightweight desktop environments suitable for low-resource systems. LXDE is based on the GTK toolkit, and LXQt is based on the Qt toolkit to provide a fast and simplified user interface. For more information, see LXQt.

  • MATE Desktop

    Based on GNOME 2, MATE Desktop adopts the traditional desktop layout and is stable and lightweight. MATE Desktop is suitable for users who prefer classic desktop experience. Supported application editions include Ubuntu MATE and Linux Mint MATE editions. For more information, see MATE Desktop.

Precautions

  • ECS instances that run Alibaba Cloud Linux operating systems do not support GUI desktop installation.

  • Before you install a GUI desktop on an ECS instance, we recommend that you create snapshots for the instance to back up your data. For more information, see Create a snapshot.

  • A GUI desktop depends on a large number of components. However, installing a large number of components on an ECS instance may degrade the performance of the instance. If you do not properly install the components, the operating system may not start as expected. Proceed with caution.

  • After you install a GUI desktop on an ECS instance, the GUI desktop automatically appears when you connect to the instance by using Virtual Network Computing (VNC). If you connect to the instance by using Workbench or Session Manager, the GUI desktop does not automatically appear.

Important
  • The following sections describe how to install a GUI desktop on ECS instances that run CentOS 7, CentOS 8, Ubuntu 14, Ubuntu 18, Ubuntu 20, and Ubuntu 22. The operations that you must perform to install a GUI desktop may vary for other distributions For more information, see the official documentation of the corresponding distribution.

  • CentOS 6 and CentOS 8 have reached their end of life (EOL). In accordance with Linux community rules, all content were removed from the default CentOS 6 and CentOS 8 repository addresses. If you continue to use the default repository addresses of CentOS 6 or CentOS 8, an error is reported. We recommend that you change the repository addresses of CentOS 6 or CentOS 8. For more information, see How do I change CentOS 6 repository addresses? or Change CentOS 8 repository addresses.

Install a GUI desktop on a CentOS 7 instance

This section describes how to install a MATE Desktop environment on an ECS instance that runs CentOS 7. The operations that you must perform to install a GUI desktop may vary for other distributions. For more information, see the official documentation of the corresponding distribution.

  1. Connect to a CentOS 7 instance by using VNC. For more information, see Connect to an instance by using VNC.

  2. Run the following command to update the software packages in the operating system:

    sudo yum -y upgrade
  3. Run the following commands in sequence to install a MATE Desktop environment:

    sudo yum groups install "X Window System"
    sudo yum groups install "MATE Desktop"
  4. Run the following command to set the default boot target to the GUI mode: You can run the systemctl set-default multi-user.target command to set the default boot target to the multi-user (text-based) mode.

    sudo systemctl set-default graphical.target
  5. Run the following command to restart the ECS instance:

    sudo reboot
  6. Wait until the system restart is complete. If the GUI desktop appears, the installation is successful.

    Note

    You can enter the username and password of the instance to connect to the instance without the need to provide the VNC logon password.

    image

Disable the GUI desktop

To disable the GUI desktop on the CentOS 7 instance, perform the following steps:

  1. Connect to the ECS instance and open the terminal emulator.

  2. Run the following commands.

    # View all package groups that are installed in the operating system.
    sudo yum group list installed
    
    # Uninstall the MATE Desktop environment.
    sudo yum groupremove "MATE Desktop"
    
    # Uninstall X Window System.
    sudo yum groupremove "X Window System"
    
    # Automatically remove dependencies that are no longer needed.
    sudo yum autoremove
    
    # Set the default boot target to the multi-user (text-based) mode.
    sudo systemctl set-default multi-user.target
    
    # Restart the operating system.
    sudo reboot

    After you perform the preceding steps, the CentOS 7 operating system uninstalls the GUI desktop and enters the text-based mode when the operating system restarts.

Install a GUI desktop on a CentOS 8 instance

This section describes how to install a GUI desktop on an ECS instance that runs CentOS 8. The operations that you must perform to install a GUI desktop may vary for other distributions. For more information, see the official documentation of the corresponding distribution.

  1. Connect to a CentOS 8 instance by using VNC. For more information, see Connect to an instance by using VNC.

  2. Run the following command to update the software packages in the operating system:

    sudo yum -y upgrade
  3. Run the following command to install the GUI desktop package:

    sudo yum groupinstall "Server with GUI" -y 
  4. Run the following command to set the default boot target to the GUI mode. You can run the systemctl set-default multi-user.target command to set the default boot target to the multi-user (text-based) mode.

    sudo systemctl set-default graphical.target
  5. Run the following command to restart the ECS instance:

    sudo reboot
  6. Wait until the system restart is complete. If the GUI desktop appears, the installation is successful.

    Note

    You can enter the username and password of the instance to connect to the instance without the need to provide the VNC logon password.

    image

Disable the GUI desktop

To disable the GUI desktop on the CentOS 8 instance, perform the following steps:

  1. Connect to the ECS instance and open the terminal emulator.

  2. Run the following commands.

    # Remove the GUI desktop package group.
    sudo yum groupremove "Server with GUI" -y
    
    # Set the default boot target to the multi-user (text-based) mode.
    sudo systemctl set-default multi-user.target
    
    # (Optional) Switch to the multi-user (text-based) mode.
    sudo systemctl isolate multi-user.target
    
    # Restart the operating system.
    sudo reboot

    After you perform the preceding steps, the CentOS operating system uninstalls the GUI desktop. After the operating system is restarted, it enters the text-based mode.

Install a GUI desktop on a Ubuntu 14 instance

This section describes how to install a GNOME desktop on an ECS instance that runs Ubuntu 14. The operations that you must perform to install a GUI desktop may vary for other distributions. For more information, see the official documentation of the corresponding distribution.

  1. Connect to a Ubuntu 14 instance by using VNC. For more information, see Connect to an instance by using VNC.

  2. Run the following command to update the software repository:

    sudo apt-get update
  3. Run the following commands in sequence to install a GNOME desktop environment:

    sudo apt-get install x-window-system-core
    sudo apt-get install gnome-core
  4. Run the following command to start the GUI desktop:

    sudo startx
  5. Run the following command to restart the ECS instance:

    sudo reboot
  6. Wait until the system restart is complete. If the GUI desktop appears, the installation is successful.

    Note

    You can enter the username and password of the instance to connect to the instance without the need to provide the VNC logon password.

    image

Disable the GUI desktop

To disable the GUI desktop on the Ubuntu 14 instance, perform the following steps:

  1. Connect to the ECS instance and open the terminal emulator.

  2. Uninstall the GNOME and X Window System core packages.

    If you run the apt-get command to uninstall core GUI desktop packages, run the following command:

    sudo apt-get purge x-window-system-core gnome-core
  3. Remove the display manager.

    In most cases, a GNOME desktop uses GDM as the display manager. To uninstall GDM, run the following command:

    sudo apt-get purge gdm

    If you use another display manager, such as LightDM, run the following command to uninstall the display manager:

    sudo apt-get purge lightdm
  4. Clear dependencies that are no longer needed.

    Run the following autoremove command to remove automatically installed dependencies that are no longer needed:

    sudo apt-get autoremove
  5. Check whether the operating system starts in text-based mode.

    Ubuntu 14.04 uses Upstart to initialize the operating system. To ensure that the operating system does not load the GUI desktop on startup, change the default boot target. Run the following command to open the configuration file that contains the default boot target:

    sudo vim /etc/default/grub

    Find the following line:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

    Change the line to the following content:

    GRUB_CMDLINE_LINUX_DEFAULT="text"

    Press the Esc key, enter :wq, and then press the Enter key to save and close the file. Then, run the following command to update the GRand Unified Bootloader (GRUB) configuration:

    sudo update-grub
  6. Reboot the operating system for the changes to take effect.

    sudo reboot

    If the operating system starts in text-based mode, the GUI desktop is disabled.

Install a GUI desktop on a Ubuntu 18, Ubuntu 20, Ubuntu 22, or Ubuntu 24 instance

This section describes how to install a Ubuntu Desktop environment on an ECS instance that runs Ubuntu 18. The operations that you must perform to install a GUI desktop may vary for other distributions. For more information, see the official documentation of the corresponding distribution.

  1. Connect to a Ubuntu 18 instance by using VNC. For more information, see Connect to an instance by using VNC.

  2. Run the following command to update the software repository:

    sudo apt-get update
  3. Run the following command to install a GUI desktop:

    sudo apt-get install ubuntu-desktop

    If the "unmet dependencies" error is reported during the installation process, use the solution described in the FAQ section of this topic to resolve the issue. Then, start the GUI desktop.

  4. Run the following command to set the default boot target to the GUI mode. You can run the systemctl set-default multi-user.target command to set the default boot target to the multi-user (text-based) mode.

    sudo systemctl set-default graphical.target
  5. Run the following command to restart the ECS instance:

    sudo reboot
  6. Wait until the system restart is complete. If the GUI desktop appears, the installation is successful.

    Note

    You can enter the username and password of the instance to connect to the instance without the need to provide the VNC logon password.

    The welcome page shown in the following figure indicates that the GUI desktop is installed.欢迎界面

  7. Repeatedly click Next to accept the default settings.

    The interface shown in the following figure indicates that the GUI desktop is installed and available for use.桌面配置完成

    Disable the GUI desktop

    To disable the GUI desktop on the Ubuntu instance, perform the following steps:

    1. Connect to the ECS instance and open the terminal emulator.

    2. Set the default boot target to the multi-user (text-based) mode.

      To ensure that the GUI desktop is no longer loaded the next time the operating system starts, set the default boot target to the multi-user (text-based) mode.

      sudo systemctl set-default multi-user.target
    3. Uninstall the ubuntu-desktop package.

      sudo apt-get purge ubuntu-desktop
    4. Uninstall the packages related to the GUI desktop.

      The following sample code provides a sample command used to remove the common packages related to the GNOME desktop environment and remove the gdm3 display manager package. If you use a different desktop environment or display manager, such as LightDM, adjust the package names accordingly.

      sudo apt-get purge gnome-shell gnome-session gdm3

      Take note that you may need to remove additional packages based on the GUI desktop components that you install. To find GUI desktop-related packages, run the following command:

      sudo dpkg -l | grep -E "gnome|xorg|lightdm|kde|plasma"

      Then, individually uninstall the GUI desktop-related packages based on the command output.

    5. Automatically remove the dependencies that are no longer needed.

      Run the autoremove command to clear dependencies that are no longer needed.

      sudo apt-get autoremove --purge
    6. Update the GRUB configuration and restart the operating system.

      sudo update-grub
      sudo reboot

      The following command output indicates that the GUI desktop is disabled for Ubuntu 18.服务版

Install a GUI desktop on an Anolis 8 instance

Anolis 8 is based on Red Hat Enterprise Linux (RHEL) and CentOS 8. You can use the Dandified YUM (DNF) package manager to install a desktop environment. To install a GUI desktop, such as the GNOME desktop, on an ECS instance that runs Anolis 8, perform the following steps:

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

  2. Update the software packages in the operating system.

    sudo dnf update -y
  3. Install a GUI desktop environment.

    sudo dnf groupinstall "Server with GUI" -y

    You can also install a different desktop environment, such as KDE Plasma. Sample command:

    sudo dnf groupinstall "KDE Plasma Workspaces" -y

    To view all available desktop environment groups, run the following command:

    sudo dnf group list
  4. Set the default boot target to the GUI mode.

    After the installation is complete, set the default boot target of the system to the GUI mode.

    sudo systemctl set-default graphical.target
  5. Start the GUI desktop.

    If you immediately switch to the GUI desktop, you do not need to restart the operating system.

    sudo systemctl isolate graphical.target

    If you want to switch to the GUI desktop by restarting the operating system, run the following command:

    sudo reboot
  6. (Optional) Install additional graphical tools.

    After the installation is complete, you may need to install additional graphical tools or drivers to ensure that the GUI desktop smoothly runs. For example, run the following command to install graphical drivers:

    sudo dnf install xorg-x11-drv-* -y
  7. Wait until the system restart is complete. If the GUI desktop appears, the installation is successful.

    Note

    You can enter the username and password of the instance to connect to the instance without the need to provide the VNC logon password.

    image

  • Run the following commands to ensure that the GUI service is started and running:

    sudo systemctl status gdm
    sudo systemctl start gdm
  • Check the current default boot target to ensure that graphical.target is returned.

    sudo systemctl get-default
  • Check logs.

    If issues occur, you can view the related logs for more information.

    sudo journalctl -xe

After you complete the preceding steps, Anolis 8 starts and enters the GUI desktop.

Disable the GUI desktop

To disable the GUI desktop on the Anolis 8 instance, perform the following steps:

  1. Connect to the ECS instance and open the terminal emulator.

  2. Set the default boot target to the multi-user (text-based) mode.

    On the GUI desktop, open the terminal emulator and run the following command to set the default boot target to multi-user.target (text-based mode):

    sudo systemctl set-default multi-user.target
  3. Immediately switch to the multi-user (text-based) mode.

    Run the following command to switch to the multi-user (text-based) mode without the need to restart the operating system:

    sudo systemctl isolate multi-user.target
  4. Uninstall the packages related to the GUI desktop.

    Run the dnf command to uninstall the package group related to the GUI desktop. Query the package groups of all installed software and find the name of the package group related to the GUI desktop. In most cases, the name is "Server with GUI" or "Graphical Desktop."

    sudo dnf group list --installed

    After you find the name of the package group related to the GUI desktop, run the following command to uninstall the packages in the package group. Replace "Server with GUI" with the actual name of the package group.

    sudo dnf groupremove "Server with GUI"
  5. (Optional) Disable and stop the graphical display manager.

    If a graphical display manager, such as GDM or LightDM, is installed on your operating system, you can run the following commands to disable and stop the graphical display manager. In this example, GDM is used.

    sudo systemctl disable gdm
    sudo systemctl stop gdm

    Replace the name of the graphical display manager in the preceding commands with the actual name.

  6. Restart the operating system for the changes to take effect.

    sudo reboot

After the operating system is restarted, it enters the text-based mode and no longer loads the GUI desktop.

FAQ

What do I do if I cannot use my keyboard or mouse after I install a GUI desktop on a CentOS instance?

Problem description

When you connect to an ECS instance by using VNC in the ECS console after you install a GUI desktop on the instance, you cannot use your keyboard or mouse.

Cause

An exception related to the driver of the keyboard or mouse occurs.

Solution

Perform the following steps to change the driver type to evdev:

  • Run the following command to install the evdev program:

    yum install xorg-x11-drv-evdev
  • Run the following command to create the /etc/X11/xorg.conf configuration file:

    Xorg -configure
  • Run the following command to back up the configuration file:

    cp xorg.conf.new /etc/X11/xorg.conf
  • Modify the /etc/X11/xorg.conf configuration file and change the type of the mouse and keyboard drivers to evdev.

    Identifier "Keyboard0"
    Driver "evdev"       # Change the driver type to evdev.
    Option "Device" "/dev/input/event3"
    EndSection
    Section "InputDevice"
    Identifier "Mouse0"
    Driver "evdev"       # Change the driver type to evdev.
    Option "Device" "/dev/input/event5"
    Option "Mode" "Absolute"
    EndSection
    • The following figure shows a sample configuration file before modification.

    • The following figure shows a sample configuration file after modification.

  1. Restart the ECS instance and check whether you can use the mouse and keyboard.

What do I do if I cannot use the GNOME desktop on a CentOS instance because the messagebus and haldaemon services are not started on system startup?

Problem description

After you install the GNOME desktop environment on a CentOS instance and restart the instance, you cannot connect to the instance even if you provide the correct username and password. The following error message appears:

"You are currently trying to run as the root super user. The super user is a specialized account that is not designed to run a normal user session. Various programs will not function properly, and actions performed under this account can cause unrecoverable damage to the operating system."

Cause

The preceding issue occurs because the messagebus and haldaemon services are not automatically started on system startup. To improve system performance and stability, the messagebus and haldaemon services are not configured to automatically start on system startup in Linux public images.

Solution

  1. Use a snapshot created before you install the GUI desktop to roll back the operating system. For more information, see Roll back a disk by using a snapshot.

  2. Perform the operations described in this topic to re-install the GUI desktop.

  3. Run the following commands to configure the messagebus and haldaemon services to automatically start on system startup:

    chkconfig --level 35 messagebus on
    chkconfig --level 35 haldaemon on
    Note

    We recommend that you set the boot level to level 3 and start the desktop environment by running the startx command to test the availability of the desktop environment. If an issue occurs, you can switch to the text-based mode to identify and troubleshoot the issue. After you confirm that the desktop environment starts as expected, change the boot level to level 5.

What do I do if the "unmet dependencies" error occurs when I install a GUI desktop on a Ubuntu instance?

Problem description

An error is reported when you install a GUI desktop on a Ubuntu 18 instance, as shown in the following figure.安装报错

Cause

Recent versions of the update-manager-core, libparted2, and python3-update-manager packages exist on the instance. However, previous versions of the packages are required to install the GUI desktop for Ubuntu 18. You must delete the recent versions of the packages so that the operating system re-installs software packages based on the software package dependency tree.

Solution

  1. Run the following command to uninstall the recent versions of the update-manager-core, libparted2, and python3-update-manager packages:

    apt-get remove update-manager-core libparted2 python3-update-manager
  2. Run the following commands to re-install the GUI desktop:

    apt-get update
    apt-get install ubuntu-desktop

What do I do if the "Invalid configuration value: failovermethod=priority" error message appears?

When you run the yum groupinstall "Server with GUI" -y command, the Invalid configuration value: failovermethod=priority error message appears.

Problem description

Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
CentOS Linux 8 - AppStream

Cause

An invalid configuration option (failovermethod=priority) exists in the configuration file of the Extra Packages for Enterprise Linux (EPEL) repository. The path of the configuration file is /etc/yum.repos.d/CentOS-epel.repo. In CentOS 8, the Yellowdog Updater Modified (YUM) package manager is based on the DNF package manager. The DNF package manager no longer supports the failovermethod configuration option. When the DNF package manager parses the configuration file of the EPEL repository, the preceding error is reported.

Solution

Modify the configuration file of the EPEL repository to remove or comment out the failovermethod=priority line. Perform the following steps:

  1. Modify the configuration file of the EPEL repository.

    Open the /etc/yum.repos.d/CentOS-epel.repo file by using your preferred text editor, such as vim or nano. Example:

    sudo vi /etc/yum.repos.d/CentOS-epel.repo
  2. Find and remove the failovermethod=priority line.

    In the configuration file of the EPEL repository, find the line that contains the failovermethod=priority configuration option. Use one of the following methods to comment out or delete the line:

    • Add the comment symbol (#) to the beginning of the line to comment out the line.

      # failovermethod=priority
    • Delete the line that contains the failovermethod=priority configuration option.

  3. # Save and close the file.

    • If you use the vim editor, press the Esc key, enter :wq, and then press the Enter key to save and close the file.

    • If you use the nano editor, press Ctrl+O to save the change and then press Ctrl+X to close the file.

  4. Clear the YUM or DNF cache.

    Run the following commands to clear the cache and ensure that the new configurations take effect:

    sudo yum clean all
    sudo yum makecache

    You can also run the following dnf commands:

    sudo dnf clean all
    sudo dnf makecache
  5. Re-install the GUI desktop.

       sudo yum groupinstall "Server with GUI" -y

How to resolve the stuttering issue

After you install a graphical user interface, a stuttering issue may happen. This may be due to the high resource consumption of the selected desktop environment or low system configuration.

Xrdp can invoke the Remote Desktop (mstsc) program that comes with Windows, providing better stability. Especially in good network conditions, Xrdp can provide a smoother experience for remote use. Refer to the following commands to install Xrdp:

sudo apt install xrdp -y
sudo adduser xrdp ssl-cert
sudo ufw allow 3389/tcp
sudo systemctl status xrdp
sudo systemctl enable xrdp

If the Linux system lacks sufficient resources or the desktop environment is too heavy, we recommend that you use a more lightweight desktop environment to improve performance.

References

Refer to the following topics, which guide you on how to build a GUI on a simple application server and use the tool of Virtual Network Console (VNC) Viewer to access the server.