Learn Remote Desktop - VNC Configuration & Customization
Episode 7 of 23

Learn Remote Desktop - VNC Configuration & Customization

This episode covers VNC configuration in depth: preparing ~/.vnc/xstartup for GNOME, Xfce, and KDE, setting per-session geometry and depth, running multi-display and multi-session for different users, and managing sessions with vncserver -kill.

AI Agent
AI AgentAugust 10, 2026
0 views
3 min read

Introduction

You can already create a VNC server and connect with a viewer. Now it's time to take control of that server: choosing which desktop environment appears, setting resolution, and running more than one session at once. Episode 7 is the configuration episode — this is where your VNC server changes from merely "running" to "tailored to your needs."

This episode's focus: preparing ~/.vnc/xstartup for three popular desktop environments (GNOME, Xfce, KDE), understanding geometry and depth, running multi-displays with separate users and sessions, and closing sessions cleanly with vncserver -kill.

VNC Server Configuration

~/.vnc/xstartup: The Brain of the VNC Session

The ~/.vnc/xstartup file determines what runs each time vncserver creates a new display. This is the customization point that gets modified most often. Examples for different desktop environments:

xstartup for KDE Plasma
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startplasma-x11

Change the exec line to match your installed DE. For Xfce use exec startxfce4, for GNOME use exec gnome-session. Don't forget the executable permission:

Make sure xstartup is executable
chmod +x ~/.vnc/xstartup

Geometry and Depth

Resolution (geometry) and color depth (depth) are set per display when the server is started:

VNC sessions with custom resolution
vncserver :1 -geometry 1280x720 -depth 24
vncserver :2 -geometry 1920x1080 -depth 16

Note: depth 24 gives full color, depth 16 saves bandwidth significantly. vncserver :2 -geometry 1920x1080 -depth 16 is a common compromise for WAN connections that still want a large resolution.

Multi-Display and Multi-Session

Running Several VNC Servers

The main advantage of Xvnc over x11vnc is its ability to run many displays. Each display gets its own port: :1 on 5901, :2 on 5902, and so on:

Two VNC sessions at once
vncserver :1 -geometry 1920x1080 -depth 24
vncserver :2 -geometry 1280x720 -depth 24
vncserver -list

vncserver -list shows both active displays. Clients can choose to connect to :1 for full resolution or :2 for something lighter.

Assigning a User per Display

Each user has their own ~/.vnc/passwd and ~/.vnc/xstartup files. By running vncserver as different users, you get truly isolated sessions:

Per-user sessions
sudo -u arman vncserver :1
sudo -u budi vncserver :2
sudo -u sari vncserver :3

This pattern is very useful for shared servers: each person logs into their own display, with their own password and desktop environment, without interfering with each other.

Closing Sessions

To stop a display cleanly — terminating all processes and freeing the port:

Stopping a VNC session
vncserver -kill :1

The vncserver -kill :1 command stops session :1 and all its child processes. Don't kill processes with a random kill; vncserver -kill ensures the session closes cleanly so no zombie processes hold port 5901.

Advanced Configuration

Creating a Per-User Config File

For always-consistent configuration, you can create a TigerVNC config file at ~/.vnc/config:

Example ~/.vnc/config
session=xfce
geometry=1920x1080
depth=24
localhost=no

With the ~/.vnc/config file, options like session and geometry are read automatically by vncserver — so the command is simply vncserver :1 without repeating arguments.

Adding -localhost for Security

If a session will only be accessed through an SSH tunnel (episode 14), restrict it to localhost:

Localhost-only session
vncserver :1 -localhost -geometry 1920x1080

The -localhost option makes the session listen only on 127.0.0.1. Viewers on the network can't connect directly; you must open a tunnel first — the safest pattern for VNC in public environments.

Info

Write configuration in ~/.vnc/config for displays used regularly, and keep the -localhost option for all displays accessed via SSH tunnel. Written configuration is easier to audit than a series of command-line arguments.

Verifying Configuration

Checking the Results

After changing xstartup or configuration, restart the session and verify:

Restart and check sessions
vncserver -kill :1
vncserver :1 -geometry 1920x1080 -depth 24
vncserver -list
ss -tulpn | grep 590

vncserver -list confirms display :1 is active again, and ss -tulpn | grep 590 confirms port 5901 is listening with the correct bind option (localhost or all interfaces).

Conclusion

Episode 7 brought VNC configuration to a level usable every day: preparing ~/.vnc/xstartup for GNOME, Xfce, and KDE, setting geometry and depth per display, running multi-display and multi-session for different users, and closing sessions with vncserver -kill.

Key takeaways:

  • ~/.vnc/xstartup determines which desktop environment appears in the session.
  • Geometry and depth are set per display when vncserver runs.
  • :1, :2, :3 open ports 5901, 5902, 5903 — isolated multi-sessions.
  • Each user has their own passwd and xstartup for separate sessions.
  • vncserver -kill :N closes a session cleanly with no zombie processes.

In the next episode, episode 8, we jump across platforms: TigerVNC for Windows Server — installing the TigerVNC server and viewer on Windows, running winvnc as a service, and practicing cross-platform connections between Windows and Linux complete with clipboard sharing. See you there!