VNC for remote access to Ubuntu with xfce4 shell

VNC is an abbreviation for Virtual Network Computing. is a cross-platform screen-sharing designed to operate another machine remotely. This means that a user using a secondary device can utilize a ’s screen, keyboard, and mouse as if they were sitting right in front of it.

There are numerous methods for connecting to a remote desktop. Consider one of several in detail – the VNC system. In this example, Ubuntu Server 16.04 with the xfce4 graphical interface is used.

initial stages

Let’s get Ubuntu ready for by installing the VNC package and the xfce4 graphical .

sudo apt-get update
sudo apt-get install xfce4 xfce4-goodies tightvncserver xorg lightdm

Important! Before installing new software, be sure to update local packages (first line).

We set password protection for to the remote desktop by typing the line:


VNC distinguishes between two types of passwords: full access and view only. View-only is the remote access system’s phrase. It is advised to set two distinct values.


Let’s move on to setting up the VNC server part, the values ​​of which are stored in the ~/.vnc/xstartup file. The VNC server is activated on port 5901, but it is registered in the system as “: 1”. Accordingly, when launched on others, numbers are assigned in order – “: 2”, “: 3”, etc.

1. First, deactivate the first port.

vncserver –kill :1

This is required for the remote access system to be configured further.

2. Be sure to create a backup copy of the settings:

mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

Important! The backup has the extension .BAK

3. Open it through the built-in Vi utility:

vi ~/.vnc/xstartup

Let’s add three lines:

xrdb $HOME/.Xresources
startxfce4 &

The graphical shell has been relocated to the server’s autorun menu.

4. Let’s adjust the access rights to the xstartup file. Allow activation access.

sudo chmod +x ~/.vnc/xstartup

5. Add a user and create a startup . Open via Vi:

sudo vi /etc/init.d/vncserver

We make adjustments, as shown in the screenshot. An explanation of each item is below:

Screenshot #1. Script for VNC server.

Change the username in the first line to the required one.

The second section of the text modifies the display settings, including resolutions, color depth, color quality, and other factors.

When VNC is active, the third block begins logging.

The final lines end the program and terminate the service, and the final section connects the commands for opening and closing VNC.

6. Add the rights to activate the code

sudo chmod +x /etc/init.d/vncserver

7. Now let’s open remote access by port forwarding.

iptables -A INPUT -p tcp --dport 5901 -j ACCEPT

8. Activate autostart of the service at VNC startup and restart it to apply the changes.

sudo update-rc.d vncserver defaults
sudo service vncserver start

The desktop will start, which is not yet available via a . Let’s complete the process.

vncserver -kill :1

9. We proceed to the start of additional services on the VNC server.

sudo /etc/init.d/lightdm start
sudo /etc/init.d/x11-common start

Activate the display and desktop manager (lightdm and x11-common).

10. Now let’s start the remote desktop so that the administrator can connect to it.


Do not forget that with each connection a new connection is opened, that is, new ports. Accordingly, for each will have to perform forwarding. The command looks like this:

iptables -A INPUT -p tcp --dport 59zz -j ACCEPT
, where zz are the digits of the port for which we are opening access.

11. Now we launch the VNC client and connect to the server. For example, through the program Remmina, UltraVNC, Vino, etc.


Welcome to the world of DomainRooster, where roosters (and hens) rule the roost! We're a one-stop shop for all your entrepreneurial needs, bringing together domain names and website hosting, and all the tools you need to bring your ideas to life. With our help, you'll soar to new heights and hatch great success. Think of us as your trusty sidekick, always there to lend a wing and help you navigate the sometimes-complex world of domain names and web hosting. Our team of roosters are experts in their fields and are always on hand to answer any questions and provide guidance. So why wait? Sign up today and join the ranks of the world's greatest entrepreneurs. With DomainRooster, the sky's the limit! And remember, as the saying goes, "Successful people do what unsuccessful people are not willing to do." So don't be afraid to take that leap of faith - DomainRooster is here to help you reach for the stars. Caw on!