Linux simple application servers provide only CLIs. 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 16.04.

Prerequisites

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

Background information

This topic describes how to use VNC to build a GUI on Ubuntu 16.04. This topic also shows how to use VNC Viewer to connect to the GUI from an on-premises Windows machine. If you need to use VNC to build a GUI on Ubuntu 18.04 or 20.04, see Use VNC to build GUIs on Ubuntu 18.04 and 20.04.

Step 1: Build a GUI

  1. Connect to the Ubuntu server.
  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
    3. Run the following command to start VNC:
      vncserver
      The first time you start VNC, you need to set a logon password. Enter a password and verify the password.
      Notice The password can be up to eight characters in length. If the string that you set contains more than eight characters, VNC uses the first eight characters as the password.
      If the command output includes the information shown in the following figure, VNC is started. Start VNC

      izbp166dsac66tx****:1 indicates the display ID of the VNC session that is started on the server. izbp166dsac66tx**** is the hostname.

  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 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 configuration 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 content:
        gnome-panel &
        gnome-settings-daemon &
        metacity &
        nautilus &
        gnome-terminal &
      The following figure shows the modified lines in the configuration file.Configuration file of VNC
    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 is 1.
      vncserver :1

Step 2: Use VNC Viewer to connect to the Ubuntu server

  1. Download and install VNC Viewer on your computer.
    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 about Ubuntu Desktop and click OK.
    You must configure the following parameters: adasdada
  4. Double-click the card of Ubuntu Desktop.
    In this example, double-click the card of the test Ubuntu Desktop.
  5. In the Authentication dialog box, enter the logon password of VNC in the Password field and click OK.
    password
    The following figure shows an example Ubuntu GUI. If you need to open a terminal in the Ubuntu GUI, right-click Open Terminal in the Ubuntu GUI. Ubuntu DesktopIf you cannot use VNC Viewer to connect to the VNC server, make sure that you configure ports 5900 and 5901 that are required for VNC in the firewall of the Ubuntu server. For more information, see Add a firewall rule. 2358