How to Use the VNC Remote Desktop Functionality on Linux

Commands, Syntax, and Examples

Virtual network computing software initiates a desktop environment on one machine sourced from other computers through an internet connection. VNC supports persistent desktops even after disconnection, so you can continue working exactly where you left off when you re-connect.

Select VNC and tap CONTINUE.

How Virtual Network Computing Works

Install vncserver on the server machine (if not already installed) and a VNC viewer on the client machine (see realVNC for a popular version of the VNC software). It's helpful to use ssh to connect from your viewer machine to the server. The PuTTY package works great for this purpose.

Launch an ssh session, then login to the server and, from the shell prompt, enter:

New '" (juser)' desktop is

Before running vncserver, set up the initialization file ~/.vnc/xstartup, which should be created in your home directory. This file contains initialization commands, such as

# Execute common xstartup file 
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
# Load .Xresources file
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
# Run the vncconfig helper to enable clipboard transfers and control of the desktop
vncconfig -iconic &
# Launch a GNOME desktop
exec gnome-session &

Now a virtual desktop runs on the server waiting to be displayed on your local computer.

If you installed the realVNC software or downloaded a VNC viewer, run this viewer, and enter the server and display number as illustrated in this example:

The viewer software asks for a password. The first time you use VNC on this server, enter a new password, which will be saved in the .vnc folder. The password is for VNC connections and not related to your user account on the server. After a period of inactivity, you may be asked to enter your account password as well to authorize the server access.

After the password is accepted, the desktop window appears with all the specified graphical user interface elements. Disconnect from the desktop by closing the desktop window.

Terminate the VNC server process by entering the following command in a shell window on the server:

vncserver -kill :

For example:

vncserver -kill :6 
Was this page helpful?