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.
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 for 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 18.04 and Ubuntu 20.04.
This topic also shows how to use VNC Viewer to connect to the GUI from an on-premises
Windows machine. If you want to use VNC to build a GUI on Ubuntu 16.04, see Use VNC to build GUIs on Ubuntu 16.04.
Step 1: Build a GUI
- Connect to the Ubuntu server.
- Run the following command to switch to the
root
user:
- Install the software package.
- Run the following command to update the software repository:
- Run the following command to install the software package that is required by the
desktop environment:
The software package includes desktop applications such as system panels, window managers,
file browsers, and terminals.
apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal ubuntu-desktop
When you install the software package, the system displays the following message.
Enter
y and press
Enter.

Follow the on-screen instructions to install the software package.
- Configure VNC.
- Install VNC.
- Run the following command to start VNC:
vncserver
The first time you use VNC, you must set the VNC logon password, enter the password,
and then confirm the password. You must enter
n as prompted, and press
Enter.

Notice The logon password of VNC can be up to 8 characters in length. If the 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 that is provided in the red box as
shown in the following figure, VNC is started.

izbp166dsac66tx****:1 indicates the port number of the VNC that is started on the
server. izbp166dsac66tx**** is the host name.
- Run the following command to back up the xstartup configuration file of VNC:
cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
- Run the following command to modify the xstartup configuration file of VNC:
- Press the i key to enter the edit mode and modify the configuration file to 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 &
- Press the Esc key, enter
:wq
, and then press the Enter key to save and close the file.
- Restart VNC.
- Run the following command to close the active VNC session:
- 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 connect to the Ubuntu server
- Download and install VNC Viewer on your computer.
Visit the
official VNC website to obtain the download link and installation instructions for VNC Viewer.
- Start VNC Viewer. In the top navigation bar, choose
- In the Properties dialog box, configure the logon information of the Ubuntu desktop and click OK.
You must configure the following parameters:
- Double-click the card of the Ubuntu desktop.
In this example, double-click the card whose Ubuntu desktop name is test001
.
- In the Authentication dialog box, enter the password of the VNC in the Password field and click OK.
After you log on to the VNC server, the Ubuntu GUI is displayed, as shown in the following
figure. If you need to open the terminal in the Ubuntu GUI, right-click
Open Terminal in the Ubuntu GUI.

If you cannot use the VNC Viewer tool to log on to the VNC server, make sure that
you configure the 5900 and 5901 ports that are required for VNC in the firewall of
the Ubuntu server. For more information, see
Add a firewall rule.
