Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
62 views3 pages

How To Install and Configure VNC On Ubuntu

This document provides step-by-step instructions for installing and configuring a VNC server on Ubuntu 20.04, including the installation of necessary packages, setting up user passwords, and creating configuration files. It also covers troubleshooting tips for port conflicts and how to enable the VNC service to start automatically after a reboot. The guide is intended for users looking to remotely access their Ubuntu desktop environment.

Uploaded by

Pierre Le Duc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views3 pages

How To Install and Configure VNC On Ubuntu

This document provides step-by-step instructions for installing and configuring a VNC server on Ubuntu 20.04, including the installation of necessary packages, setting up user passwords, and creating configuration files. It also covers troubleshooting tips for port conflicts and how to enable the VNC service to start automatically after a reboot. The guide is intended for users looking to remotely access their Ubuntu desktop environment.

Uploaded by

Pierre Le Duc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Pages / … / IT Operational Procedures

How to install and configure VNC on Ubuntu


Created by Tina Rakotoarivelo, last modified by Daniel Francis Sebastian Charles on Sep 27, 2023

The following instructions will help you set up a VNC server on your Ubuntu desktop and allow you to connect to
desktop session remotely.

This procedure has been tested in Ubuntu 20.04 and validated the same.

Step-1: Install xfce4 (graphical environment) and tightvncserver package on the target desktop

# sudo apt install xfce4 tightvncserver

Step-2: Uninstall tigervnc-server if exist and insall tigervnc-viewer

# sudo apt purge tigervnc-server && sudo apt install tigervnc-viewer

Step-3: Set Password for VNC User


Note: Switch to the target user and set the VNC password

$ vncpasswd

Step-4: Create a xstartup configuration file under target user's home directory:
Note: Create a .vnc directory first if not exists

$ vim /home/$USER/.vnc/xstartup

#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey &
vncconfig -iconic &
exec startxfce4

Step-6: Give execute permission to the xstartup configuration

# sudo chmod +x /home/$USER/.vnc/xstartup

Step-7: Create a system configuration file for the VNC service


Note: Change the User and Group name accordingly to the target user
# vim /etc/systemd/system/[email protected]

[Unit]
Description= Tiger VNC Server service
After=syslog.target network.target

[Service]
Type=forking
User=$USER
Group=$GROUP
Restart=always

ExecStartPre=/bin/bash -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'


ExecStart=/usr/bin/vncserver -geometry 1920x1080 -depth 24 :%i
ExecStop=/bin/bash -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

Step-8: Reload the system daemon to reflect the changes

# systemctl daemon-reload

Step-9: Enable VNC service to start automatically after server reboot

# systemctl enable [email protected]

Step-10: Restart the VNC service

# systemctl restart [email protected]

General Troubleshooting:

If the port 5901 is already used by some other service, then VNC service may fail to start it. Check the log "journalctl -xe"
for more details.

# netstat -tunlp | grep 5901

In order to remediate this port conflict issue, create a new VNC configuration service with port 5902.
Step-1: Stop the existing VNC service

# systemctl stop [email protected]

Step-2: Disable the VNC service

# systemctl disable [email protected]

Step-3: Enable a new VNC service again

# systemctl enable [email protected]

Step-4: Start the VNC service

# systemctl start [email protected]

If the VNC service is failing post config changes, reboot the system once and check it.

Note: Share the same port to the user to access the system along with password.

No labels

You might also like