All Products
Search
Document Center

Simple Application Server:Use VNC to build an Ubuntu 18.04 or Ubuntu 20.04 GUI

Last Updated:Dec 19, 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 GUI.

Prerequisites

A simple application server that runs the Ubuntu 18.04 or Ubuntu 20.04 OS and has the specification of 1 vCPU and 2 GB of memory or higher specification is created. For more information, see Create a simple application server.

Background information

This topic describes how to use VNC to build an Ubuntu 18.04 or Ubuntu 20.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 16.04 GUI, see Use VNC to build an Ubuntu 16.04 GUI.

Step 1: Build a GUI

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

    For more information, see Connect to a Linux server.

  2. Install the software package.

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

      apt-get update
    2. Run the following command to install the software package for the desktop environment.

      The software package includes desktop applications, such as a system panel, window manager, file browser, and terminals.

      apt install -y gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal ubuntu-desktop
  3. Configure VNC.

    1. Run the following command to install VNC:

      Ubuntu 18.04

      apt-get install vnc4server

      Ubuntu 20.04

      apt-get install tightvncserver

      If the following message appears, enter Y and press Enter.1258

    2. Run the following command to start VNC:

      vncserver

      The first time you start VNC, you must set a logon password for VNC. Enter a logon password and verify the password. Enter n in the following message and press Enter.2558

      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. Run the following command to back up the xstartup configuration file of VNC:

      cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
    4. Run the following command to modify the xstartup configuration file of VNC:

      vim ~/.vnc/xstartup
    5. Press I to enter the edit mode and replace the content of the configuration file with the following content.

      #!/bin/sh
      export XKL_XMODMAP_DISABLE=1
      export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME"
      export XDG_MENU_PREFIX="gnome-flashback-"
      gnome-session --session=gnome-flashback-metacity --disable-acceleration-check &
    6. 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 -geometry 1920x1080 :1

Step 2: Use VNC Viewer to access the Ubuntu server

  1. Enable ports 5900 and 5901 in the firewall rule of the Ubuntu server. These ports are required by the VNC service. For more information, see Manage a firewall.

    image

  2. Download and install VNC Viewer on your Windows computer.

    You can visit the official VNC website to obtain the download link and installation instructions for VNC Viewer.

  3. Start VNC Viewer. In the top navigation bar, choose File > New connection...

    VNC Viewer

  4. 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: 114.55.XX.XX:5901. For information about how to obtain the public IP address of an Ubuntu server, see the "How do I obtain the public IP address of my simple application server" section of the FAQ topic.

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

  5. Double-click the card of the Ubuntu desktop.

    In this example, double-click the card of the Ubuntu desktop named test001.

  6. 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.2588

    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 Manage a firewall.

    • 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 about remote connection.