How to Install & Configure VNC Server on Ubuntu 22.04 or 20.04

Posted ztguang_张同光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了How to Install & Configure VNC Server on Ubuntu 22.04 or 20.04相关的知识,希望对你有一定的参考价值。

​https://bytexd.com/how-to-install-configure-vnc-server-on-ubuntu/​

 

  • by​​EdXD​
  • Updated May 28, 2022
  • VNC (Virtual Network Computing) is a visual connection system that enables you to interact with the graphical desktop environment of a remote PC using a mouse and a keyboard.
    If you have worked with Microsoft Remote Desktop Protocol (RDP) before, think of VNC as an open-source alternative.
    VNC is quite a lifesaver for many who are not comfortable working from the command-line and need to manage files, install software and configure settings on a remote server.
    In this tutorial we will go step-by-step through installing and configuring the VNC Server on an Ubuntu 22.04 or 20.04 machine, and we’ll look at how we can connect to it via VNC desktop client on our other PC using a secure SSH tunnel.
    We will also install some of the most popular desktop environments and configure the VNC server to use them.
    Let’s dive in and get started.For a guide on using Remote Desktop Protocol (RDP) with Ubuntu 22.04 / 20.04 you can also check our guide on​​using xRDP for Ubuntu 22.04 / 20.04​​​, for X2Go (which uses a modified​​NX​​​ 3 protocol) you can check our guide on using​​X2Go for Ubuntu 22.04 / 20.04​​​, or for Chrome Remote Desktop you can check our guide on​​installing Chrome Remote Desktop on an Ubuntu 22.04 / 20.04​​​. For a somewhat different take on remote desktops you can also check our​​tutorial on Xpra​​.
TABLE OF CONTENTS
  1. ​Prerequisites​
  2. ​Step 1: Install a Desktop Environment​
  3. ​Step 2: Install VNC server​
  1. ​Install TigerVNC on Ubuntu​
  1. ​Step 3: Configure the VNC server​
  1. ​Connecting to your VNC Remote Desktop​
  1. ​Step 4: Establish a secure connection to the VNC Desktop​
  1. ​Set up an SSH Tunnel with Your Terminal​
  2. ​Set up an SSH Tunnel with Putty​
  1. ​Step 5: Setting up the VNC as a system service​
  2. ​Configuring VNC to Use Other Desktop Environments (And Switching Between Them)​
  1. ​Configure VNC to Use GNOME​
  2. ​Configure VNC to Use XFCE​
  3. ​Configure VNC to Use LXQt​
  4. ​Configure VNC to Use LXDE​
  5. ​Configure VNC to Use MATE Desktop​
  6. ​Configure VNC to Use Budgie​
  7. ​Configure VNC to Use KDE Plasma Desktop​
  8. ​Configure VNC to Use Cinnamon​
  9. ​Configure VNC Deepin Desktop Environment (DDE)​
  1. ​Conclusion​

Prerequisites

  • A machine running Ubuntu 22.04 or 20.04 to which we’ll connect.
  • Acting as anon-root sudo userfor security reasons. You can see our tutorial on​​creating a sudo user in Ubuntu​​ if you need to.
  • AVNC Client(also calledVNC Viewer) which is the software that you’ll run on your local machine and will enable you to control your VNC server remotely. There are some popular VNC viewers that you can choose from. The one I’m using in this tutorial is Real VNC Viewer.
    It’s available for Windows, macOS, Linux, android, and others. You can choose your OS and​​​download Real VNC Viewer here​​​. If you’re on Linux then I prefer​​Remmina​​.

Step 1: Install a Desktop Environment

If you intend to connect via VNC to an Ubuntu 22.04 or 20.04 server, then you’ll notice that the server doesn’t come with a preinstalled Desktop Environment. On booting up, you will get a command-line interface to execute your commands.

However, that doesn’t mean you can install one.

As of writing this post, there are several Linux desktop environments available for you to install. They include GNOME desktop, KDE Plasma Desktop, Mate Desktop, Budgie Desktop, Xfce/Xubuntu Desktop, Cinnamon Desktop, and many more.

For this particular post, we will install the ​​XFCE​​ desktop environment. It is fast, stable, and easy to use.

XFCE is very popular and lightweight. If you’d like to install a different desktop environment right away, you can jump to our section below, on installing and configuring other desktop environments with VNC: ​​Configuring VNC to Use other Desktop Environments​

You can also install multiple desktop environments at the same time, and just switch between them. However, you may end up with bugs or conflicts, depending on the desktop environments you have simultaneously installed.

After establishing an SSH connection to your server, execute the following command to update your package index:

  • sudo apt update

Next we’ll run the following command to install 

  • xfce4  and  xfce4-goodies :sudo apt install xfce4 xfce4-goodiesxfce4-goodies  is an additional package forXFCE Desktop Environment, which brings a lot more advanced enhancement.

You will see a prompt to select a display manager for your newly installed XFCE Desktop Environment during the installation.

  • ADisplay Manageris a program that enables your Linux distribution to possess graphical login capabilities. It is also responsible for starting the Display Server and the Desktop Environment once you log in with your username and password.

Select any display manager and press Enter.

Step 2: Install VNC server

After successfully installing the XFCE desktop environment, we can proceed to install the VNC server.

There are several VNC servers available for Linux today. They include TightVNCx11VNC, and TigerVNC.

For this particular tutorial, we will install the ​​TigerVNC​​ server.

  • The reason for choosingTigerVNCis because I got it to work with the most desktop environments.
  • Initially I triedTightVNCand got it to work with XFCE, LXQt, LXDE, KDE Plasma, and Gnome Flashback, but struggled withGNOME 3and Budgie. I didn’t try MATE or Cinnamon, however.

Install TigerVNC on Ubuntu

To install TigerVNC execute the command below:

  • sudo apt install tigervnc-standalone-server

After a successful installation, we need to perform the initial VNC configuration, set up a VNC access password and initialize the VNC server.

Execute the command below to initialize the VNC server instance and set up a password. Assuming you are acting as a non-root sudo user, do NOT execute this command with 

  • sudo :vncserver Set VNC Password You will require a password to access your desktops.   Password: Verify:Note:The password must be between 6 – 8 characters long. The system will automatically truncate any password longer than eight characters. For example, if you enter a password likestartup2233, it will be truncated tostartup2.

After setting up the password, you will get a prompt to set a View-Only password. That means anybody who accesses the VNC server with a view-only password will not be able to VNC desktop with either Mouse or Keyboard.

For this particular post, we won’t set up a view-only password. I will just type N and hit Enter.

  • Finish Setting VNC Password Would you like to enter a view-only password (y/n)? N /usr/bin/xauth: file /home/edxd/.Xauthority does not exist   New bytexd:1 (edxd) desktop at :1 on machine bytexd   Starting applications specified in /etc/X11/Xvnc-session Log file is /home/edxd/.vnc/bytexd:1.log   Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/edxd/.vnc/passwd :1 to connect to the VNC server.

We can see this process lists the connection information for our VNC server from the message above. Additionally, it started the VNC server at port 

  • 5901 , which is the display port. This port (5901) is referred to as  :1 .

If you create additional VNC server instances, they will be presented as port 5902 as 

  • :2 , port5903as  :3 , and so on.

Up to this point, our VNC server is up and running. However, it cannot give us access to a graphical interface since it’s not configured to launch our XFCE desktop environment;

  • Tip:If you ever want to change the VNC password or the view-only password, execute the command below:vncpasswd

Step 3: Configure the VNC server

Up to this point, we have successfully installed the VNC server and even set up a password.

Now we need to configure the commands that will be executed by the server every time we start a VNCV instance.

One main goal is telling VNC which Desktop Environment to connect and use – in this case, XFCE.

To get started, let’s kill the running VNC instance that we launched in Step 2 above running on port 

  • 5901 . Execute the command below:vncserver -kill :1 Output Killing Xtigervnc process ID 28634... success!

If another instance were running on another port, say 5902 or 5903, we would execute the commands 

  • vcnserver -kill :2  and  vncserver -kill :3 , respectively.

To configure VNC, we will need to create a file called 

  • xstartup  file in the.vncfolder under thehomedirectory ( ~/.vnc/xstartup ). This is where we’ll configure what desktop environment we want the VNC server to use.In my case,TigerVNCdoes not create the~/.vnc/xstartupfile by itself. If in your case it does, then you can just back up the existing one by running  mv ~/.vnc/xstartup ~/.vnc/xstartup.bak , and create a new file.

Now, let’s create and open a new 

  • xstartup  file with the  nano  editor. Execute the commands below:nano ~/.vnc/xstartup

Add the lines below on the editor:

  • ~/.vnc/xstartup #!/bin/sh   # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS   /usr/bin/startxfce4   [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &

Save the file (Ctrl + O, then Enter) and Exit (Ctrl + X).

Lastly, we need to make this file executable. Run the command below:

  • chmod +x ~/.vnc/xstartup

Once done, proceed to restart the VNC server with the command below.

  • vncserver -localhost no :1 Restart VNC Output New bytexd:1 (edxd) desktop at :1 on machine bytexd   Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/edxd/.vnc/passwd :1 to connect to the VNC server.

The above command launches a VNC server instance on port 5901.

  • Why we used -localhost no

By default, TigerVNC accepts connection only from 

  • 127.0.0.1  or  localhost , for security reasons. Since we’re just testing now, we added  -localhost no  to be able to access the server via VNC from the outside.

We’ll cover this in a little bit more detail further in this article.

As such, before proceeding and looking at how to create a secure connection, let’s test the VNC server.

Connecting to your VNC Remote Desktop

Launch your VNC Client (or VNC Viewer) application on your local machine and connect to the VNC server using 

  • server_ip_address:1  or  server_ip_address:5901 .

In my case, I will use 

  • 149.28.227.198:1  (I’m using aVultrserver), and my VNC Client is​​Real VNC Viewer​​, which supports many operating systems including Windows, macOS and Linux.

From the image above, you can now see our VNC server is well configured, and we can access it from our local machine.

Close the VNC client desktop session and kill the VNC instance on the server using the command below:

  • vncserver -kill :1

Step 4: Establish a secure connection to the VNC Desktop

To establish a secure connection, restart your VNC server by simply running 

  • vncserver  without the  -localhost no  option as shown below.vncserver Output New bytexd:1 (edxd) desktop at :1 on machine bytexd   Starting applications specified in /home/edxd/.vnc/xstartup Log file is /home/edxd/.vnc/bytexd:1.log   Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/edxd/.vnc/passwd :1 to connect to the VNC server.

By default, TigerVNC by default, when you don’t run 

  • -localhost no , binds the server to your Ubuntu 22.04 / 20.04 serverloopback interface. That ensures that the VNC server only accepts connections incoming from the server where it is installed.

To get around this and connect to the VNC server from our local machine, we will establish an SSH tunnel from our local machine to the server. That is also an additional layer of security as only users with SSH access to the server can connect to the VNC server.

We’ll set up our SSH tunnel in one of two ways, depending on your preference – by running a command in your terminal or by configuring it in ​​Putty​​. You can choose whichever one you prefer.

Set up an SSH Tunnel with Your Terminal

You’re probably familiar with your terminal if you are on Linux or macOS. On Windows you can use PowerShell or a terminal emulator such as ​​Cmder​​.

Execute the command below on your local machine terminal emulator.

  • ssh -L 59000:localhost:5901 -C -N -l server_user_name server_ip_address

Remember to replace the server_user_name and server_ip_address accordingly. In my case, I will execute the command below:

  • ssh -L 59000:localhost:5901 -C -N -l edxd 149.28.227.198Note:After executing this command, the SSH connection will hang after you enter the password. Don’t worry that is perfectly fine.

When you are done with using the VNC Desktop session, you can kill it using Ctrl + C. Alternatively; you can add a 

  • -f  argument which runs SSH tunneling in the background.

Lets, dissect the SSH tunneling command above:

  • -L 59000:localhost:5901 : The-Largument specifies the post on your local computer (ours is59000) to the given host (localhost) and port (5901) on the destination server (server_ip_address).
    Note: The local port, 59000, can be any number but not more than 65535 and not running another service.
  • -C : This argument speeds up processes and minimizes resource usage.
  • -N : This argument prevents execution of remote commands and tells SSH to only forward ports.
  • -l server_user_name server_ip_address : This line specifies the user you will use to login to the server. Make sure the user isnon-rootand doesn’t have root privileges.

Now to connect securely to your VNC server, launch the VNC client application and connect with the address 

  • localhost:59000 :

Set up an SSH Tunnel with Putty

If you are connecting to your server using Putty, create an SSH tunnel using the procedure below. Launch Putty and enter your server’s address in the session > hostname.

On the left side of the Putty window, scroll down and get to the SSH option. Extend it and select the Tunnels option. Enter the details as shown in the image below—Port 

  • 59000  as the source port and  localhost:5901  as the destination address.

When done, click Add, then Open/Apply to create the SSH tunnel. You can now connect to the VNC server using the VNC client address: 

  • localhost:59000 .

Step 5: Setting up the VNC as a system service

The advantage of setting up VNC as a service is that we can start, stop, restart or even view its status (whether it’s running or not) just like we would for other system services. We will also use systemd to launch our VNC server on boot.

To get started, let’s create a unit file called vncserver@.service using the command below:

  • sudo nano /etc/systemd/system/vncserver@.service

Paste the lines below and remember to replace the 

  • YOUR_USERNAME  text with your username, and  -depth 24 -geometry 1280x800  with thedepthandgeometryyou prefer.
  • -depth: represents the color depth, in bits per pixel. The value can be between 8 and 32.
  • -geometry: the width and height of the desktop.
  • [Unit] Description=Start TigerVNC server at startup After=syslog.target network.target   [Service] Type=forking User=YOUR_USERNAME Group=YOUR_USERNAME WorkingDirectory=/home/YOUR_USERNAME   PIDFile=/home/YOUR_USERNAME/.vnc/%H:%i.pid ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1 ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 -localhost :%i ExecStop=/usr/bin/vncserver -kill :%i   [Install] WantedBy=multi-user.targetSave the file (Ctrl + O, thenEnter) and Exit (Ctrl + X).

Now we need to make the system aware of our new unit file. Execute the commands below:

  • sudo systemctl daemon-reload sudo systemctl enable vncserver@1.service Output Created symlink /etc/systemd/system/multi-user.target.wants/vncserver@1.service → /etc/systemd/system/vncserver@.service.

With that done, we can now start, stop and restart our VNC server as a system service. To test this, let’s first stop the instance that we had launched previously with the command below:

  • vncserver -kill :1

Once done, let’s now start the VNC server as a service. Execute the command below:

  • sudo systemctl start vncserver@1

To check its status and confirm whether its running or not, use the command below:

  • sudo systemctl status vncserver@1 ● vncserver@1.service - Start TigerVNC server at startup Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2021-07-23 11:37:59 UTC; 5s ago Process: 83157 ExecStartPre=/usr/bin/vncserver -kill :1 > /dev/null 2>&1 (code=exited, status=0/SUCCESS) Process: 83162 ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 -localhost :1 (code=exited, status=0/> Main PID: 83170 (Xtigervnc) Tasks: 166 (limit: 2270) Memory: 236.5M CGroup: /system.slice/system-vncserver.slice/vncserver@1.service ├─83170 /usr/bin/Xtigervnc :1 -desktop bytexd:1 (edxd) -auth /home/edxd/.Xauthority -geometry 1280x80> ├─83180 xfce4-session ├─83191 /usr/bin/dbus-launch – sh-syntax – exit-with-session xfce4-session ├─83192 /usr/bin/dbus-daemon – syslog – fork – print-pid 5 – print-address 7 – session ├─83198 /usr/libexec/at-spi-bus-launcher ├─83203 /usr/bin/dbus-daemon – config-file=/usr/share/defaults/at-spi2/accessibility.conf – nofork – > ├─83207 /usr/lib/x86_64-linux-gnu/xfce4/xfconf/xfconfd ├─83213 /usr/libexec/at-spi2-registryd – use-gnome-session ├─83219 /usr/bin/ssh-agent -s ├─83223 xfwm4 ├─83227 /usr/libexec/gvfsd ├─83238 xfsettingsd ├─83239 xfce4-panel ├─83245 Thunar – daemon ├─83250 xfdesktop ├─83251 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugi> ├─83252 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugi> ├─83253 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugi> ├─83256 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugi> ├─83257 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugi> ├─83270 /usr/lib/x86_64-linux-gnu/xfce4/notifyd/xfce4-notifyd ├─83273 /usr/libexec/geoclue-2.0/demos/agent ├─83281 xiccd ├─83282 /usr/lib/x86_64-linux-gnu/tumbler-1/tumblerd ├─83283 /usr/bin/python3 /usr/share/system-config-printer/applet.py ├─83287 nm-applet ├─83289 /usr/libexec/evolution-data-server/evolution-alarm-notify ├─83302 /usr/libexec/dconf-service ├─83308 xfce4-power-manager ├─83339 /usr/libexec/evolution-source-registry ├─83348 /usr/libexec/goa-daemon ├─83356 /usr/libexec/goa-identity-service ├─83363 /usr/libexec/evolution-calendar-factory ├─83376 /usr/libexec/evolution-addressbook-factory ├─83394 /usr/libexec/gvfs-udisks2-volume-monitor ├─83400 /usr/libexec/gvfs-goa-volume-monitor ├─83405 /usr/libexec/gvfs-gphoto2-volume-monitor ...

From the image above, we can see that we have successfully started VNC as a service.

That’s it! You have successfully installed and configured the VNC server on Ubuntu 22.04 / 20.04 LTS, and you can now manage it just like any system service.

Configuring VNC to Use Other Desktop Environments (And Switching Between Them)

To configure VNC to use a desktop environment with TigerVNC we have to:

  1. Install the desktop environment on our Ubuntu 22.04 / 20.04 machine
  2. Appropriately edit the~/.vnc/xstartupfile where we tell VNC what applications to start on our behalf when it creates a new desktop. In this section, where we mention what contents to add to the~/.vnc/xstartupfile, we’ll assume the file is empty.
  3. Restart the VNC server after you’ve edited the~/.vnc/xstartupfile.
    If you set up the VNC service as a system service you can restart it by running:sudo systemctl start vncserver@1If you don’t have it set up as a system service then you can just kill the VNC instance and start it again:vncserver -kill :1 vncserver
  4. For more details on how to install other desktop environments, please check our related tutorial on​​how to install a desktop environment (GUI) on an Ubuntu 20.04 server​​, where you can also find some additional details on each desktop environment. You can also install just minimal versions of desktop environments, with minimal necessary software packages, or full versions with all the bells and whistles. In this tutorial we’ll stick to minimal installs for demonstration purposes.

Please keep in mind that if you install multiple desktop environments on the same machine, then you may encounter bugs or conflicts, depending on which you have installed.

Configure VNC to Use GNOME

  • As mentioned before, and in case someone stumbles upon this article looking specifically for how to use GNOME with VNC on Ubuntu 22.04 / 20.04, I recommendTigerVNC instead of TightVNC.

To install GNOME on Ubuntu 22.04 / 20.04 we’ll run:

  • sudo apt install gnome-session gnome-terminal

And to configure VNC to use GNOME create a new ~/.vnc/xstartup file or edit the existing one, and paste in the following:

  • #!/bin/sh   # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS   /usr/bin/gnome-session   [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &

Make the file executable in case it isn’t already:

  • chmod +x ~/.vnc/xstartup

Now restart the VNC server, and when you connect to it you should be using GNOME.

Here’s how the GNOME minimal installation looks like in my case:

And this is how the full GNOME desktop looks like, if you install it with the following command:

  • sudo apt install ubuntu-desktopNote:I know I said that we’d install only minimal versions, but I wanted to give you an idea of the differences.

This is how the full GNOME Desktop install it looks like:

Configure VNC to Use XFCE

We covered this initially in the tutorial, but will add it here too, so the article is more easily skimmable.

To install XFCE run:

  • sudo apt install xfce4 xfce4-goodies

To configure VNC to use XFCE create a new ~/.vnc/xstartup file or edit the existing one, and paste in the following:

  • #!/bin/sh   # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS   /usr/bin/startxfce4   [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &

Make the file executable in case it isn’t already:

  • chmod +x ~/.vnc/xstartup

Now restart the VNC server and next time you connect you should be using XFCE.

This is what XFCE looks like:

Configure VNC to Use LXQt

To install LXQt run:

  • sudo apt install lxqt

To configure VNC to use LXQt create a new ~/.vnc/xstartup file, or edit the existing one, and paste in the following:

  • #!/bin/sh   # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS   /usr/bin/startlxqt   [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &

Make the file executable in case it isn’t already:

  • chmod +x ~/.vnc/xstartup

Now restart the VNC server and next time you connect you should be using LXQt.

This is what LXQt looks like in my case:

Configure VNC to Use LXDE

To install LXDE run:

  • sudo apt install lxde

To configure VNC to use LXQt create a new ~/.vnc/xstartup file, or edit the existing one, and paste in the following:

  • #!/bin/sh   # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS   /usr/bin/startlxde   [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &

Make the file executable in case it isn’t already:

  • chmod +x ~/.vnc/xstartup

Now restart the VNC server and next time you connect you should be using LXDE.

This is what LXDE looks like in my case:

Configure VNC to Use MATE Desktop

To install MATE Desktop run:

  • sudo apt install ubuntu-mate-desktop

To configure VNC to use MATE Desktop create a new ~/.vnc/xstartup file, or edit the existing one, and paste in the following:

  • #!/bin/sh   # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS   /usr/bin/mate-session   [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &

Make the file executable in case it isn’t already:

  • chmod +x ~/.vnc/xstartup

Now restart the VNC server and next time you connect you should be using MATE Desktop.

This is what MATE Desktop looks like in my case:

Configure VNC to Use Budgie

To install Budgie run:

  • sudo apt install ubuntu-budgie-desktop

To configure VNC to use Budgie create a new ~/.vnc/xstartup file, or edit the existing one, and paste in the following:

  • #!/bin/sh   # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS   /usr/bin/budgie-session   [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &

Make the file executable in case it isn’t already:

  • chmod +x ~/.vnc/xstartup

Now restart the VNC server and next time you connect you should be using Budgie.

This is what Budgie looks like in my case:

Configure VNC to Use KDE Plasma Desktop

To install KDE Plasma Desktop run:

  • sudo apt install kde-plasma-desktop

To configure VNC to use KDE Plasma Desktop create a new ~/.vnc/xstartup file, or edit the existing one, and paste in the following:

  • #!/bin/sh   # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS   /usr/bin/startplasma-x11   [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &

Make the file executable in case it isn’t already:

  • chmod +x ~/.vnc/xstartup

Now restart the VNC server and next time you connect you should be using KDE Plasma Desktop.

This is what KDE Plasma Desktop looks like in my case:

  • VNC with KDE Plasma Desktop on Ubuntu 22.04VNC with KDE Plasma Desktop on Ubuntu 20.04

Configure VNC to Use Cinnamon

To install Cinnamon run:

  • sudo apt install cinnamon-desktop-environment

To configure VNC to use Cinnamon create a new ~/.vnc/xstartup file, or edit the existing one, and paste in the following:

  • #!/bin/sh   # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS   /usr/bin/cinnamon-session   [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &

Make the file executable in case it isn’t already:

  • chmod +x ~/.vnc/xstartup

Now restart the VNC server  and next time you connect you should be using Cinnamon.

This is what Cinnamon looks like in my case:

Configure VNC Deepin Desktop Environment (DDE)

  • As of updating this article (May 5th 2022) I could only install Deepin on Ubuntu 20.04, and not Ubuntu 22.04. We’ll update the article as soon as we can for Ubuntu 22.04.

To install Deepin first add the stable PPA for DDE:

  • sudo add-apt-repository ppa:ubuntudde-dev/stable

Update your package index:

  • sudo apt update

Install Deepin Desktop Environment:

  • sudo apt install ubuntudde-dde

To configure VNC to use Deepin create a new ~/.vnc/xstartup file, or edit the existing one, and paste in the following:

  • #!/bin/bash unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS export XKL_XMODMAP_DISABLE=1 export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=@im=fcitx   #__using_dde__ session=startdde   #__enable_clipboard_sync__ if [ -f /usr/bin/autocutsel ] then /usr/bin/autocutsel -fork fi   #__deepin_uos_activator__ if [ -f /usr/bin/uos-activator ] then /usr/bin/uos-activator & fi   #__enable_fcitx__ if [ -f /usr/bin/fcitx ] then (sleep 15 && /usr/bin/fcitx) & fi   #__kill_user_apps_duplicated__ killall -9 xxx &   exec dbus-launch $session Thanks to​​this gist​​ for the xstartup contents.

This is what Deepin looks like in my case:

Conclusion

I believe this guide has given you a step-by-step guide on installing and configuring a VNC server on Ubuntu 22.04 or 20.04. Feel free to share any additional VNC configuration tips with our readers or ask any questions in the comments below or by contacting us.




以上是关于How to Install & Configure VNC Server on Ubuntu 22.04 or 20.04的主要内容,如果未能解决你的问题,请参考以下文章

how to install git 1.8 rpm

ubuntu——How to Install MySQL GUI

How to Install The Alpha Control Packages.

How to install Lion

how to install hive

markdown How-To-Install-NodeJS.md