ProductsDesktop Server For Scientific Computing For IBM POWER For IBM System z For SAP Business Applications Red Hat Network Satellite ManagementExtended Update Support High Availability High Performance Network Load Balancer Resilient Storage Scalable File System Smart Management Extended Lifecycle SupportWeb Server Developer Studio Portfolio Edition JBoss Operations Network FuseSource Integration Products Web Framework Kit Application Platform Data Grid Portal Platform SOA Platform Business Rules Management System (BRMS) Data Services Platform Messaging JBoss Community or JBoss enterprise
SolutionsApplication development Business process management Enterprise application integration Interoperability Operational efficiency Security VirtualizationMigrate to Red Hat Enterprise Linux Systems management Upgrading to Red Hat Enterprise Linux JBoss Enterprise Middleware IBM AIX to Red Hat Enterprise Linux HP-UX to Red Hat Enterprise Linux Solaris to Red Hat Enterprise Linux UNIX to Red Hat Enterprise Linux Start a conversation with Red Hat Migration services
TrainingPopular and new courses JBoss Middleware Administration curriculum Core System Administration curriculum JBoss Middleware Development curriculum Advanced System Administration curriculum Linux Development curriculum Cloud Computing and Virtualization curriculum
ConsultingStandard Operating Environment (SOE) Strategic Migration Planning Service-oriented architecture (SOA) Enterprise Data Solutions Business Process Management
Issue #6 April 2005
- What's new in security for Red Hat Enterprise Linux 4
- Taking advantage of SELinux in Red Hat Enterprise Linux
- The security dilemma, part 2: Intrusion prevention
- It's 2 a.m., do you know who's reading your email?
- Video: See you at the Summit
- Taking your desktop virtual with VNC
- Video: Open source software licenses explained
- Video: Ticketmaster chooses Red Hat Enterprise Linux and Strongmail
- Open source in the force: One officer speaks
- Red Hat Knowledgebase: Serving apple pie to the masses
- Data sharing with a GFS storage cluster
- Red Hat Training adds Windows®-to-Linux® migration course
From the Inside
In each Issue
- Editor's blog
- Red Hat speaks
- Ask Shadowman
- Tips & tricks
- Fedora status report
- Magazine archive
Taking your desktop virtual with VNC
by Tim Waugh
- Applications of VNC
- Setting up a persistent desktop
- Using a VNC viewer
- Quick steps
- Further reading
- About the author
Every day when I finish work, I switch off my desktop computer. When I switch it on again the following morning, I can carry on where I left off. I switch on the computer, and all of my application windows are exactly where I left them. The web browser is still showing me the webpage I was half-way through reading. How? I use Virtual Network Computing: VNC.
My desktop session actually runs on another machine in another building. The desktop computer I sit in front of runs a VNC viewer and shows me my desktop—but the applications in that desktop are running inside a VNC server session.
Applications of VNC
There are several different problems that can be solved by using VNC. The reason I use it is so that I can have a persistent desktop as previously described. This is one of the most common reasons for using VNC. One computer runs a VNC server, which is a type of virtual frame buffer: it manages a screen image (a two-dimensional array of pixels), but does not display it directly on a screen. Another computer runs a VNC viewer, which acts as a client and takes the frame buffer image from the VNC server and displays it on a real screen. With VNC providing a persistent desktop, I do not need to log in or log out, but instead I just resume my session from where I left off last time by running a VNC viewer application.
VNC servers and viewers are available for a variety of operating systems. Red Hat® Enterprise Linux® 4 includes the server and two viewers: a Java version as well as the native application. The VNC server can be configured to provide the Java viewer over HTTP, so you can use any Java-enabled web browser on any operating system as a VNC viewer.
The design of VNC places few demands on the VNC viewer. Most of the work is done by the server. As a result of this, it is a well-placed technology for making thin client systems (where a number of diskless machines provide graphical interfaces to a single powerful server). Thin clients need only run the VNC viewer whereas the applications can reside on the server.
One type of thin client is an X terminal: a dedicated machine that runs the X Window System and is connected to a network. In general, these machines are configured to connect to a server which then displays a login window. The X terminal displays the graphics from the server using the X Window System protocol.
A VNC viewer can act like a software X terminal, with a VNC server providing the login window. The advantage of using VNC for this is that the login session will stay there even when the user disconnects the VNC viewer, moves to another room or building, then reconnects. The session only finishes when the user logs out; afterwards, connecting with a VNC viewer will show a login window again.
Another use for VNC is to remotely control or view a display. Several methods for doing this are included with Red Hat Enterprise Linux 4. The easiest to use is the Allow other users to view your desktop and Allow other users to control your desktop. In this dialog box you can also set a password for VNC access and ask require when a VNC viewer connects as shown in Figure 1. Remote desktop.entry in the -> menu. To allow your session to be viewed or controlled, click the check buttons labeled
A less easy but more efficient way of achieving the same effect is to use the VNC loadable module for the X Window System. Instructions for setting this up can be found at the RealVNC website. Using this module, even when no one is logged in, the login window on the screen can be viewed and controlled remotely.
With Red Hat Enterprise Linux 4, VNC can make life easier even while you install the operating system! You probably already know that unattended automatic installations are possible using the kickstart feature, with the installation options and package selections being set out in advance in a kickstart file. You may not know that you can have interactive control of the Red Hat Enterprise Linux installation procedure even when the machine being installed is physically remote from you, perhaps even in another country.
The installing Red Hat Enterprise Linux machine can be told
to act as a VNC server from the very beginning of the
installation. Very briefly, the way to do this is to boot using
PXE (or any similar method), passing the command line
linux ks vnc to the installer (links to
documentation about PXE network installations can be found in
the section called “Further reading”). Provide a minimal kickstart
file using DHCP, which just sets the location of the installation
directory—perhaps an NFS server. When the installer starts
you will be able to start a VNC viewer and connect to the IP
address of the machine.
Setting up a persistent desktop
Here is a description of the steps to take when setting up a persistent desktop using VNC in Red Hat Enterprise Linux 4.
The first thing to do is set a password for the VNC server.
To do this, log in as normal and run the command
vncpasswd from a shell prompt. The VNC service
will not start unless you have set a password.
Next, become root using
su - and edit the
/etc/sysconfig/vncservers file. To set up
two persistent desktop sessions, one for
fred and one for
joe (who prefers a larger display
fred), it should look
like Example 1. /etc/sysconfig/vncservers example.
# The VNCSERVERS variable is a list of display:user pairs. # # Uncomment the line below to start a VNC server on display :1 # as my 'myusername' (adjust this to your own). You will also # need to set a VNC password; run 'man vncpasswd' to see how # to do that. # # DO NOT RUN THIS SERVICE if your local area network is # untrusted! For a secure way of using VNC, see # <URL:http://www.uk.research.att.com/vnc/sshvnc.html>. VNCSERVERS="1:fred 2:joe" # fred's VNC options VNCSERVERARGS="-geometry 1024x768" # joe's VNC options VNCSERVERARGS="-geometry 1280x1024"
To start all VNC persistent desktops at boot, enable the VNC
chkconfig vncserver on (as
root). Then, to start the VNC persistent desktops now, type
service vncserver start. Both users will
be able to connect VNC viewers,
fred to display number 1 and
joe to display number 2.
The default desktop session in VNC is a very simple one, using the
twm window manager. You might prefer the VNC
desktop session to look and behave the same as the login session you would
normally see. To do that, edit the file
and remove the
# from the beginning of the
two lines that follow the line reading
following two lines for normal desktop.
Using a VNC viewer
Whether you use the Java VNC viewer or a native VNC viewer on Red Hat Enterprise Linux 4, Microsoft® Windows®, or any other platform, the procedure is broadly the same. On Red Hat Enterprise Linux 4 the application can be found in the menu as-> -> .
A dialog box will appear asking for a VNC server to connect to, and an Options... button allows you to configure certain things about how the VNC viewer will operate.
The VNC server is identified by a hostname (or IP address)
and a display number. If the
/etc/sysconfig/vncservers file in Example 1. /etc/sysconfig/vncservers example was on a machine named
hoopoe.elk, the VNC server for
joe's session would be
The VNC display number is not an IP port number even though
syntax is used for specifying port numbers in a web browser. To
make matters slightly more confusing, the Java VNC viewer is
accessed in this way when using a web browser by specifying a port
number! The port number for the Java VNC viewer is the display
number plus 5800. For example, to get to
joe's VNC session using a web
browser the URL would be
If a password is set on the VNC server, the VNC viewer prompts you for it. Next, the VNC viewer window appears containing the desktop session (see Figure 2. VNC Viewer window). Closing the VNC viewer window does not terminate the desktop session.
To adjust connections settings, press F8 for the menu (refer to Figure 3. VNC Viewer menu. Running a VNC viewer in mode allows it to catch key combinations that would normally be intercepted by the window manager, for example Alt-Tab to switch between windows. In mode, this switches between windows in the VNC session, not between the VNC viewer window and other windows on the local session.
Pressing F8 brings up the VNC menu, but if you want an application running in the VNC session to get the keypress instead of the VNC viewer, select from the VNC menu.
Here is a quick recap of the steps needed to set up a persistent desktop using VNC on Red Hat Enterprise Linux 4.
- Set a password using
- Enable the service with
chkconfig vncserver on
- Start the service with
service vncserver start
/home/username/.vnc/xstartupif you want a more advanced session than just twm and an xterm
- RealVNC—documentation from the original developers of VNC
- PXE Network Installations—from the Red Hat Enterprise Linux documentation
- Kickstart Installations—from the Red Hat Enterprise Linux documentation
Next month, part two of this series will discuss how to troubleshoot the VNC setup and include some tips on making VNC faster.