Ubuntu. Installing VNC and using it over a remote connection

Sometimes becomes necessary to work on a server not through the console, but through the remote desktop. The remote system VNC (Virtual Network Computing) comes to the rescue. Consider how to install, configure and connect to the server.


Update information about repositories:

sudo apt-get update

Update the system components and restart the server:

sudo apt-get upgradereboot

Let’s get to the installation.

sudo apt-get install --no-install-recommends -desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal vnc4server

This process is not very fast, as more than 200 megabytes will be downloaded.

To complete the initial configuration of the VNC server, run the command:


The program will ask for a password and its confirmation to connect via VNC, and will also create scripts.


Under the setting, it should be understood that the commands and scripts that should be executed when the server is started will be indicated. To do this, you need to edit the ~/.vnc/xstartup file. The VNC server, by default, is initialized on tcp port 5901, which is called the “Display port”, in the VNC documentation it is referred to as “:1”. VNC itself allows you to run multiple instances of :2 – 5902, :3 – 5903, and so on.

I am leaving the service on port 5901:

vncserver -kill :1

We edit the settings file, for this we open it in any text editor, nano:

nano ~/.vnc/xstartup

Add 4 lines to the end of the file:

gnome-panel &gnome-settings-daemon &metacity &nautilus &

The general form of the file should look like this

We start with the command:


It can be seen that the server started on tcp port 5901.

We connect to the server using any VNC client, such as Remmina.

Select the protocol – VNC. Specify the server address and the port through a colon, in the particular case And click on the “Connect” button

The program will ask you to enter a password.

Here is the result.

Important! If protection is used, then you should add an allow rule for the connection:

iptables -A INPUT -p tcp --dport 5901 -j ACCEPTiptables-save

It is also important to remember that the allow rule must be for each running server instance in the form of:

iptables -A INPUT -p tcp --dport 59XX -j ACCEPTiptables-save

XX – port number :2 – 02, :3 – 03, :10 – 10.


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!