The No-BS Guide to VNC on Ubuntu Server 22.04 (It Actually Works)

:desktop_computer: Setting Up a VNC Server on Ubuntu Server 22.04 (The Captain Dumbass Way)

Get remote access without setting your desktop or sanity on fire.
:penguin::laptop::rocket::hammer_and_wrench:


So you’ve got a box running Ubuntu Server 22.04, and you want GUI access from afar — not just a terminal, but actual windows, apps, and maybe even a browser or two. Enter: VNC. But if you’re expecting “just works” — well, welcome to Linux.

This guide walks through the exact process to set up a VNC server using tightvncserver, paired with the Xfce desktop, and wrapped with systemd for sanity. No command changes. Just straight-up instructions with some commentary that won’t bore you to sleep.


:gear: 1. Install the VNC Server

You’ll be doing this as user: dumbass. (Replace that with your actual username later.)

sudo apt update
sudo apt -y install tightvncserver

:artist_palette: 2. Install a Desktop Environment

You’ll need something to see when you remote in. Xfce is lightweight and just works.

sudo apt install xfce4 xfce4-goodies

You can swap in another desktop environment (GNOME, KDE, MATE) if you’re into that sort of thing — just update the startup line later.


:key: 3. Set a VNC Password

Let’s keep the door locked.

vncpasswd

Follow the prompt, enter a secure password (you’ll use it in your VNC viewer), and verify it.


:rocket: 4. Start and Kill VNC

Spin up your first session:

vncserver :1

This creates a virtual desktop on display :1 — which maps to port 5901.

Need to stop it?

vncserver -kill :1

Clean, easy, controlled chaos.


:brick: 5. Configure the VNC Startup Environment

By default, VNC doesn’t know what desktop to start. You’ll tell it.

sudo nano ~/.vnc/xstartup

Append this line at the end:

exec /usr/bin/startxfce4 &

This tells VNC to boot into Xfce when it starts.


:framed_picture: 6. Start It With Display Settings

Let’s give it a good-looking resolution.

vncserver :1 -geometry 1920x1080 -depth 24

:electric_plug: 7. Open the Right Port and Connect Remotely

If ufw isn’t installed, install it first:

sudo apt install ufw

Then allow VNC traffic:

sudo ufw allow 5901

Now grab a VNC client like RealVNC Viewer from the machine you’ll connect from.
Use your server’s IP and port 5901.


:toolbox: 8. Set Up a systemd Service

So you don’t have to start VNC manually every time the server reboots.

Create a new service definition:

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

Paste this in — replace [Add your user name] with your actual Linux username (like dumbass):

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=[Add your user name]
Group=[Add your user name]
WorkingDirectory=/home/green

PIDFile=/home/[Add your user name]/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

:counterclockwise_arrows_button: 9. Reload systemd and Start VNC the Right Way

sudo systemctl daemon-reload
sudo systemctl enable --now vncserver@1

If your VNC session from earlier is still running, shut it down first:

vncserver -kill :1

Then restart it via systemd:

sudo systemctl start vncserver@1

Want to make sure it’s alive?

systemctl status vncserver@1

:brain: Final Thoughts

You now have a clean, working, GUI-ready remote desktop setup running on Ubuntu 22.04.
You can reboot, connect, and manage the box visually — without babysitting terminal windows.


:megaphone: Got Feedback?

Did this actually work for you? Any wild configs or DE swaps?
Share your tweaks or pain in the thread — someone out there will thank you later.