logo

Setting Up VNC Server on Raspberry Pi: A Comprehensive Guide

O

Ohidur Rahman Bappy

MAR 22, 2025

Introduction

In this guide, we will walk you through the steps to set up a VNC server on your Raspberry Pi. This will allow you to access and control the Raspberry Pi remotely via a graphical desktop interface.

Installing TightVNC Server

Before you start, update your system packages:

sudo apt update
sudo apt upgrade
sudo apt install tightvncserver

Configuring the VNC Server

To start the VNC server:

vncserver :1

Starting VNC Server Manually

You can manually start the VNC server at any time:

vncserver :1

Running VNC Server at Boot

Create a new service file to run the server at boot:

sudo nano /etc/systemd/system/vncserver.service

Copy the following configuration:

[Unit]
Description=TightVNC remote desktop server
After=network.target

[Service]
User=pi
Type=forking
ExecStart=/usr/bin/vncserver :1
ExecStop=/usr/bin/vncserver -kill :1

[Install]
WantedBy=multi-user.target

Managing the Service

To start the service:

sudo systemctl start vncserver

To check the service status:

sudo systemctl status vncserver

To stop the server:

vncserver -kill :1

To enable the service at boot:

sudo systemctl enable vncserver

To stop the service:

sudo systemctl stop vncserver

To disable the service:

sudo systemctl disable vncserver

Setting the Screen Size

You can set a specific screen size:

vncserver :1 -geometry 1440x900

Installing Ubuntu Desktop Environment

Install the Ubuntu GNOME desktop:

sudo apt install ubuntu-gnome-desktop

Start and enable the desktop service:

sudo systemctl start gdm
sudo systemctl enable gdm

Installing Additional Ubuntu Packages

To enhance your desktop experience, install the following packages:

sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

Updating ~/.vnc/xstartup

Configure the VNC startup file:

# Uncomment the following two lines for a normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &

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

Installing a Fake Display

Install the dummy video driver package:

sudo apt-get install xserver-xorg-video-dummy

Add the following configuration to /etc/X11/xorg.conf:

Section "Device"
    Identifier  "Configured Video Device"
    Driver      "dummy"
EndSection

Section "Monitor"
    Identifier  "Configured Monitor"
    HorizSync 31.5-48.5
    VertRefresh 50-70
EndSection

Section "Screen"
    Identifier  "Default Screen"
    Monitor     "Configured Monitor"
    Device      "Configured Video Device"
    DefaultDepth 24
    SubSection "Display"
    Depth 24
    Modes "1024x800"
    EndSubSection
EndSection

Conclusion

You have now set up a VNC server on your Raspberry Pi, allowing remote GUI access. This setup enhances productivity, especially for users who prefer graphical management.

References

For more information, you can visit the original guide.