Linux simple application servers provide only CLI. If you want to use a GUI to manage an operating system, you can use Virtual Network Console (VNC) to build a GUI. This topic describes how to build a GUI on Ubuntu.

Prerequisites

  • A simple application server that runs an Ubuntu operating system is created. For more information, see the "Modify the configurations for a simple application balancer" section of the Create a server topic.
  • Rules are added to the firewall of the Ubuntu server to allow traffic on ports 5900 and 5901. These ports are required by the VNC service. For more information, see the "Modify the configurations for a simple application balancer" section of the Add a firewall rule topic.

Background information

This topic describes how to use VNC to build a GUI on Ubuntu and how to use VNC Viewer to access the GUI from an on-premises Windows machine. In the following examples, the Ubuntu 18.04 operating system is used.

Step 1: Build a GUI

  1. Connect to the Ubuntu server.
    For more information, see the "Modify the configurations for a simple application balancer" section of the Connect to a Linux server by using the Simple Application Server console topic.
  2. Run the following command to switch to the root user:
    sudo su root
  3. Install and configure VNC.
    1. Run the following command to update the software repository:
      apt-get update
    2. Run the following command to install VNC:
      apt-get install -y vnc4server
      Note If vnc4server fails to be installed, a possible cause is that the vnc4server package is absent from the repository of the operating system version. For example, the vnc4server package is not registered in the Ubuntu 20.04 repository by default. You can run the echo 'deb http://archive.ubuntu.com/ubuntu/ bionic universe' >> /etc/apt/sources.list command to add the software repository that contains vnc4server to the /etc/apt/sources.list file, which is the software repository configuration file of Ubuntu. Then, run the apt-get install -y vnc4server command again to install vnc4server.
    3. Run the following command to start VNC:
      vncserver
      The first time you start VNC, you must set the logon password of VNC.
      Notice The logon password of VNC can be up to 8 characters in length. If your specified string exceeds eight characters in length, VNC uses the first eight characters of the string as the password.
      If the command output includes the information in the red box as shown in the following figure, VNC is started. Start VNC

      1 in Hostname:1 is the display ID of the active VNC session. In the subsequent steps, you must use <Public IP address of the Ubuntu server>:1 in the VNC connection tool to connect to the Ubuntu GUI.

  4. Install a desktop environment.
    1. Run the following command to install X-windows:
      apt-get install -y x-window-system-core
    2. Run the following command to install the GNOME display manager gdm3:
      apt-get install -y gdm3
    3. Run the following command to install the Ubuntu desktop:
      apt-get install -y ubuntu-desktop
    4. Run the following command to install the GNOME dependency:
      apt-get install -y gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
    5. Run the following command to back up the xstartup configuration file of VNC:
      cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
    6. Run the following command to modify the xstartup configuration file of VNC:
      vi ~/.vnc/xstartup
    7. Press the I key to enter the edit mode.
      Make the following modifications to the file:
      • Add the number sign (#) to the beginning of each of the following lines to comment out the lines:
        xsetroot -solid grey
        vncconfig -iconic &
        x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
        x-window-manager &
      • Add the following information to the end of the file:
        gnome-panel &
        gnome-settings-daemon &
        metacity &
        nautilus &
        gnome-terminal &
      The following figure shows the modified lines in the configuration file. VNC configuration file
    8. Press the Esc key, enter :wq, and then press the Enter key to save and close the file.
  5. Restart VNC.
    1. Run the following command to close the active VNC session:
      vncserver -kill :1
    2. Run the following command to start a new VNC session:
      The display ID of the new VNC session remains as 1.
      vncserver :1

Step 2: Use VNC Viewer to access the Ubuntu server

  1. Download and install VNC Viewer on your computer.
    You can visit the official VNC website to obtain the download link and installation instructions for VNC Viewer.
  2. Start VNC Viewer. In the top navigation bar, choose File > New connection...
    VNC Viewer
  3. In the Properties dialog box, configure the logon information of the Ubuntu desktop and then click OK.
    You must configure the following parameters:
    • VNC Server: Enter <Public IP address of the Ubuntu server>:<Display ID of the VNC session>. Example: 114.55.XX.XX:1.
    • Name: Specify a name for the Ubuntu desktop. Example: test.
  4. Double-click the card of the Ubuntu desktop.
    In this example, double-click the card of the test Ubuntu desktop.
  5. In the Authentication dialog box, enter the password of the Ubuntu desktop in the Password field and click OK.
    password
    After you log on, the Ubuntu GUI is displayed, as shown in the following figure. Ubuntu desktop