Serverspace Black Friday
VB
February 20 2023
Updated December 6 2024

How to install VNC on the server under Ubuntu 20.04

Ubuntu VNC

What is VNC

VNC (Virtual Network Computing) - software which made your "local" keyboard and mouse as connected to the any other server. This tool provides the easy management of files, software and settings on a remote server.

Requirements to install

Although VNC-console as CLI-mode management tool is possible, it is completely senseless cause SSH is better in this scenario (except disaster-recovery). So, reason to use VNC is GUI presence. You need at least 2Gb RAM, 2 cores CPU and 20-30 GB of drive space.

Installation

You're ready now. Please follow steps below:

Update software cache and install packages via system package management tool:

apt-get update && apt install xfce4-goodies tightvncserver xfce4

pic1

Run the installed tool and set access password. You can also set separated password for "viewers" if you want:

vncserver

pic2

Kill the session:

vncserver -kill :1

pic3

Add one row to the settings file:

echo "startxfce4 &" >> /root/.vnc/xstartup

pic4

 

Add execution permissions to file:

chmod -rwxr-xr-x /root/.vnc/xstartup

pic5

Run the service again:

vncserver

pic7

Now your VNC-service is ready to use. Remember: if you prefere any VNC-client you need to add "59" before "real" port number. E.g. if  real port is "1", you must use "5901" in your client software instead:

pic7

Result like below should appear. If you've seen this - you're great!

pic8

Next step is optional: you may want ro run VNC service automatically. It is easy peasy. Create a service initial file:

cat <<EOT >> /etc/systemd/system/vnc.service

[Unit]
Description=VNC-server
After=syslog.target network.target

[Service]
Type=forking
User=root
PAMName=login
PIDFile=/root/.vnc/%H:1.pid
ExecStartPre=-/usr/bin/vncserver -kill :1 > /dev/null 2>&1
ExecStart=/usr/bin/vncserver
ExecStop=/usr/bin/vncserver -kill :1

[Install]
WantedBy=multi-user.target
EOT

pic9

Enable our service and launch it:

systemctl enable vnc

systemctl start vnc

pic10

Conclusion

Now you may organize an easy access to the your server's desktop environment and set this access permanently working.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 2
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.