All Products
Search
Document Center

Simple Application Server:Use VNC to build an Ubuntu 16.04 GUI

Last Updated:Feb 02, 2024

Linux simple application servers provide only CLIs. If you want to use a GUI to manage the Linux OS of your simple application server, you can use Virtual Network Console (VNC) to build a GUI. This topic describes how to build an Ubuntu 16.04 GUI.

Prerequisites

  • A simple application server that runs Ubuntu is created. For more information, see Create a simple application server.

  • Firewall rules are added to the firewall of the Ubuntu server to allow traffic over ports 5900 and 5901. These ports are required by the VNC service. For more information, see the "Add a firewall rule" section of the Manage a firewall topic.

Background information

This topic describes how to use VNC to build an Ubuntu 16.04 GUI. This topic also shows how to use VNC Viewer to connect to the GUI from an on-premises Windows machine. For information about how to use VNC to build an Ubuntu 18.04 or Ubuntu 20.04 GUI, see Use VNC to build an Ubuntu 18.04 or Ubuntu 20.04 GUI.

Step 1: Build a GUI

  1. Connect to your Ubuntu server as the root user.

    For more information, see the "(Recommended) Method 1: Connect to a Linux server by using Workbench in the Simple Application Server console" section in the Connect to a Linux server topic.

  2. 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 must set a logon password. Enter a password and verify the password.

      Important

      The logon password of VNC can be up to eight characters in length. If the string that you specify contains more than eight characters, VNC uses the first eight characters of the string as the password.

      If the command output includes the information shown in the following figure, VNC is started.启动VNC

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

  3. 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.VNC配置文件

    8. Press the Esc key, enter :wq, and then press the Enter key to save and close the file.

  4. 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 on-premises Windows 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 about the Ubuntu desktop and click OK.

    You must configure the following parameters:

    • VNC Server: Enter <The public IP address of the Ubuntu server>:<The port number of VNC>. Example: 121.41.XX.XX:1. For information about how to obtain the public IP address of a simple application server, see the "How do I obtain the public IP address of my simple application server?" section of the How do I obtain the public IP address of my simple application server? topic.

    • Name: Enter a name for the Ubuntu desktop. Example: test.

    adasdada

  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 logon password of VNC in the Password field and click OK.

    password

    After you log on to the Ubuntu server, you can see the Ubuntu GUI, as shown in the following figure. If you want to open a terminal in the Ubuntu GUI, you can right-click the blank area in the Ubuntu GUI and select Open Terminal.Ubuntu桌面

    If you cannot use VNC Viewer to access the Ubuntu server, perform the following operations to troubleshoot the problem: dasad

    • Check whether ports 5900 and 5901 are enabled in the firewall of the Ubuntu server. These ports are required by the VNC service. For more information, see the "Add a firewall rule" section of the Manage the firewall of a server topic.

    • Check whether a firewall is configured on your on-premises computer.

    • Check whether your on-premises computer can ping the public IP address of the Ubuntu server.

    For more information, see FAQ.