fbpx

VNC (Virtual Network Computing)

VNC (Virtual Network Computing)

VNC is a graphical desktop sharing system that allows you to remotely control the desktop interface of one computer from another. It transmits the keyboard and mouse events from the controller, and receives updates to the screen over the network from the remote host.
You will see the desktop of the Linux inside a window on your computer. You’ll be able to control it as though you were working on the Linux desktop itself.
Install TightVNC on your linux via ssh.

sudo apt-get install tightvncserver

Run TightVNC Server which will prompt you to enter a password and an optional view-only password

tightvncserver

Start a VNC server from the terminal. This example starts a session on VNC display zero (:0) with full HD resolution:

vncserver :0 -geometry 1920x1080 -depth 24

Automation and run at boot
You can create a simple file with the command to run the VNC server on the Pi, to save having to remember it:
Create a file containing the following shell script:

#!/bin/sh
vncserver :0 -geometry 1920x1080 -depth 24 -dpi 96

Save this as vnc.sh (for example)
Make the file executable:

chmod +x vnc.sh

Then you can run it at any time with:

./vnc.sh

Log into a terminal on the Linux as root:

sudo -i

Create a new file here containing the following script:

nano /etc/init.d/vncboot
### BEGIN INIT INFO
# Provides: vncboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
# Description: Start VNC Server at boot time.
### END INIT INFO
#! /bin/sh
# /etc/init.d/vncboot
USER=MY_USER_NAME
HOME=/home/pi
export USER HOME
case "$1" in
start)
echo "Starting VNC Server"
#Insert your favoured settings for a VNC session
su - MY_USER_NAME -c "/usr/bin/vncserver :0 -geometry 1280x800 -depth 16 -pixelformat rgb565"
;;
stop)
echo "Stopping VNC Server"
/usr/bin/vncserver -kill :0
;;
*)
echo "Usage: /etc/init.d/vncboot {start|stop}"
exit 1
;;
esac
exit 0

You can change the MY_USER_NAME with your user.
Make this file executable:

chmod 755 vncboot

Enable dependency-based boot sequencing:

update-rc.d /etc/init.d/vncboot defaults

If enabling dependency-based boot sequencing was successful, you will see this:
update-rc.d: using dependency based boot sequencing
But if you see this:

update-rc.d: error: unable to read /etc/init.d//etc/init.d/vncboot

then try the following command:

update-rc.d vncboot defaults

Reboot your Linux and you should find a VNC server already started.

sudo reboot

On a Linux machine install the package xtightvncviewer:

sudo apt-get install xtightvncviewer

Now, on your computer, install and run the VNC client
http://www.uvnc.com/docs/uvnc-viewer.html
Enter the linux system IP address and colon 1 or 2 which is screen assigned for that instance.

Share this post