tencent cloud

Building a Visual Ubuntu Desktop
Last updated: 2025-07-28 14:16:24
Building a Visual Ubuntu Desktop
Last updated: 2025-07-28 14:16:24

Scenarios

Virtual Network Console (VNC) is a remote control tool software developed by AT&T European Research Laboratory. An open-source software based on UNIX and Linux operating systems, VNC features robust remote control capability, high efficiency, and strong practicability. Its performance is comparable to any remote control software in Windows or Mac. This document will guide you through on how to build a visual Ubuntu desktop by using VNC.

Prerequisite

Purchase a Linux CVM using Ubuntu OS.

Directions

Configuring instance security group

The VNC service uses the TCP protocol and port 5901 by default. Therefore, you need to add a rule to open TCP:5901 in the security group bound to the instance. For more information, see Adding Security Group Rules.

Installing software packages

Ubuntu 18.04
Ubuntu 20.04
Ubuntu 22.04
Ubuntu 24.04
2. Run the following command to clear the cache and update the software package list.
sudo apt clean all && sudo apt update
3. Run the following command to install the software packages required by the desktop environment, including desktop applications such as system panel, window manager, file browser, and terminal.
sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal ubuntu-desktop
4. Run the following command to install VNC.
apt-get install vnc4server
2. Run the following command to clear the cache and update the software package list.
sudo apt clean all && sudo apt update
3. Run the following command to install the software packages required by the desktop environment, including desktop applications such as system panel, window manager, file browser, and terminal.
sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal ubuntu-desktop
4. Run the following command to install VNC.
apt-get install tightvncserver
2. Clear the cache and update the software package list.
sudo apt clean all && sudo apt update
3. Install the desktop environment.
sudo apt install xfce4 xfce4-goodies
4. Run the following command to install VNC.
sudo apt install tightvncserver
2. Run the following command to clear the cache, and update the software package list.
sudo apt clean all && sudo apt update
3. Run the following command to install the required software package for the desktop environment.
sudo apt install xfce4 xfce4-goodies dbus-x11
4. Run the following command to install VNC.
sudo apt install tightvncserver

Configuring VNC

Ubuntu 18.04
Ubuntu 20.04
Ubuntu 22.04
Ubuntu 24.04
1. 
Run the following command to launch VNC and set a password.

Note:
Note: Generally, the maximum length of a VNC server password is 8 characters, so ensure the password is no more than 8 characters long.
vncserver
If the result similar to the following is returned, it indicates that VNC has been launched successfully.


2. Run the following command to access the VNC configuration file.
vi ~/.vnc/xstartup
3. Press i to enter edit mode, and modify the configuration file as follows.
#!/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 &
4. Click Esc and enter :wq to save and close the file.
5. Run the following commands to restart the desktop process.
vncserver -kill :1 # Enter the command to terminate the original desktop process (wherein :1 is the number of the desktop)
vncserver -geometry 1920x1080 :1 # Generate a new session
6. Click here to download and install VNC Viewer. Select the version that matches your operating system.
7. Type CVM IP address: 1 into VNC Viewer, and press Enter.


8. In the pop-up window, click Continue.
9. Enter the VNC password set in step 1 and click OK.
1. 
Run the following command to launch VNC and set a password.

Note:
Note: Generally, the maximum length of a VNC server password is 8 characters, so ensure the password is no more than 8 characters long.
vncserver
If the result similar to the following is returned, it indicates that VNC has been launched successfully.


2. Run the following command to access the VNC configuration file.
vi ~/.vnc/xstartup
3. Press i to enter edit mode, and modify the configuration file as follows.
#!/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 &
4. Click Esc and enter :wq to save and close the file.
5. Run the following commands to restart the desktop process.
vncserver -kill :1 # Enter the command to terminate the original desktop process (wherein :1 is the number of the desktop)
vncserver -geometry 1920x1080 :1 # Generate a new session
6. Click here to download and install VNC Viewer. Select the version that matches your operating system.
7. Type CVM IP address: 1 into VNC Viewer, and press Enter.


8. In the pop-up window, click Continue.
9. Enter the VNC password set in step 1 and click OK.
1. Run the following command to launch VNC and set a password.
Note:
Note: Generally, the maximum length of a VNC server password is 8 characters, so ensure the password is no more than 8 characters long.
vncserver
If the result similar to the following is returned, it indicates that VNC has been launched successfully.


2. Go to the VNC Viewer official website, download and install VNC Viewer of the version that matches your operating system.
3. Type CVM IP address: 1 into VNC Viewer, and press Enter.


4. In the pop-up window, click Continue.
5. Enter the password created in the previous step and click OK.
Note:
If you forgot the password, log in to the instance and execute vncpasswd to resetthe VNC login password.
Appendix: Install Chrome:
Log in to the instance and execute the following command to download .deb:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Install .deb file
sudo apt install ./google-chrome-stable_current_amd64.deb
1. 
Run the following command to start the VNC service and set the VNC password.

Note:
Note: Generally, the maximum length of a VNC server password is 8 characters, so ensure the password is no more than 8 characters long.
vncserver
The following result returns, indicating that VNC startup is successful.



2. Run the following command to open the VNC configuration file.
vi ~/.vnc/xstartup
3. Press i to switch to editing mode and modify the content of configuration file as follows.
#!/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 &
4. Press Esc, enter :wq to save the file and go back.
5. Run the following command to restart the desktop process.
vncserver -kill :1 # End the original desktop process, enter the command (where :1 is the desktop number).
vncserver -geometry 1920x1080 :1 # Generate a new session.
6. Click here to go to the VNC Viewer website, download and install the version that matches the operating system of the local computer.
7. In the VNC Viewer software, enter the CVM IP address:1 and press Enter.
Note:
Note: If the VNC client does not support specifying the desktop number (such as :1), connect via IP:port number (the port number is the desktop number + 5900, for example, port 5901 for desktop 1).

8. In the pop-up dialog box, click Continue.
9. Enter the VNC password set in Step 1, click OK, and you can log in to the instance and use the graphical interface then.

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback