Once you've installed Ubuntu Server you will need a mechanism to be able to administer it. One way is to Install Putty. Putty gives you a "Command Line" interface and so you'll need to learn a few Linux commands in order to be able to administer your server this way. Some people find this prospect rather too daunting and would rather use a graphical user interface (GUI) instead. As a result many people actually install Ubuntu Desktop instead of installing Ubuntu Server since the desktop version of Ubuntu has the GUI built in. There is a better way however, and that is to install VNC. VNC provides a "virtual desktop" so it is more lightweight than a full blown desktop installation.
NOTE: If you're jumping into this guide here then it's worth mentioning that this guide has been tested on Lucid Lynx 10.04, Karmic Koala 9.10, 9.04 Jaunty, and 8.10 Intrepid.
So to perform the installation of VNC you can either type the following commands from a Putty session or, if you've got a screen and keyboard attached to your server, then you can use the command line itself.
First off you need to type:
sudo apt-get update
You'll be prompted for a password. This is the password you created when you installed Ubuntu. Ubuntu tends to prompt for a password each time you issue a "sudo" command.
TIP: If you're going to be following this guide step by step using Putty then you can save yourself some typing by simply highlighting each command below, right-clicking on it and selecting Copy. Then toggle over to your Putty Session and right-click once more. The command you've just copied from here will be automatically pasted into your Putty Session.
First off we need to install the core Gnome components for our virtual desktop. So type the following command (or copy it!):
sudo apt-get install gnome-core
when prompted type Y and then press [Enter]. This will install the gnome desktop core components.
Now we've installed the core components for the desktop we need to install VNC to be able to interact with it. So type:
sudo apt-get install vnc4server
when prompted type Y and press [Enter]. This will install VNC Server which is required for running the virtual desktop on the server. Next type:
vncserver -geometry 1280x1024 -depth 24
where 1280x1024 is the resolution of your DESKTOP COMPUTER. It has nothing to do with the resolution of the server itself. This command will create a new VNC session on your server.
You'll then be prompted to create and verify a new password. Once you've entered it you'll see the following screen:
We now need to kill the session we just created and make a tweak to the startup script for VNCServer to make it work properly. If we don't perform this step then all we will see is a grey cross-hatched screen with an "X" cursor. Not very useful!
You're probably wondering why we just created a session and then killed it before we'd actually used it? Well, creating the session for the first time automatically generates the file we now need to edit.
So, type the following command to kill the session:
vncserver -kill :1
Now type the following command to make the tweak:
vim .vnc/xstartup
This will open up the file we need to edit.
Scroll down to the line which currently reads #unset SESSION_MANAGER and press the [Insert] key once (this will switch us into "edit" mode) and then remove the #
Do the same for the line after that. Plus change that line to read as follows:
exec sh /etc/X11/xinit/xinitrc
Note the "sh".
Change the xterm -geometry line as below
Once you've made these changes the file should look like this:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec sh /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 1280x1024+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
NOTE: On Lucid Lynx 10.04 & Maverick Meerkat 10.10 they've changed things slightly. The last 2 lines are different:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec sh /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 1280x1024+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
When you're done press the [Esc] key once and type the following:
:wq
This should save the changes and bring you back to the command line. If you make a mistake then issue :q! instead of :wq to abort your changes.
Next type:
vncserver -geometry 1280x1024 -depth 24
to create the VNC Session once more.
Next, download and install TightVNC onto your desktop computer. When you launch it type the "X Desktop name" in the VNCServer box. See the DOS-type screenshot above for the name of your "X Desktop name". So, in my case I'd type MyMediaServer:1 in the VNC Server Listbox. See below.
then click Connect, enter the password you created when you typed the vncserver -geometry 1280x1024 -depth 24 command the first time round and you should then see a screen like this:
Click the Delete button on the error message which is displayed and you now have a nice shiny desktop view onto your server!
Incase you're wondering how what we've just installed differs to simply installing the full blown Desktop version of Ubuntu then connect a screen to your server now and you'll see it's still sitting there on a black screen with a flashing cursor waiting for you to type your username in. What we've just installed is just a "virtual desktop" onto your server. Neat eh!
Currently this "virtual desktop" runs in a window on your Windows desktop. If you want to switch to "Full Screen" mode, right-click on the TightVNC icon on the taskbar on your windows desktop and select Full screen from the menu. Click OK on the next message. Now it's as tho you're actually sitting in front of your server. Very cool!
To switch out of Full Screen mode and return to Window mode press Ctrl-Esc on your keyboard to bring back your Windows Desktop taskbar. Then right-click on the TightVNC icon on the taskbar and uncheck the Full Screen option.
I know a lot of people wouldn't bother installing a virtual desktop on their servers (and I've no doubt any Linux veterans reading this will be scoffing that I've done so) but I was a total Linux newbie when I started this project and the thought of administering everything using the command line was simply too daunting a prospect. Even tho I now feel much more comfortable with Ubuntu I still find it really handy to just nip into the Ubuntu desktop and tweak something.
When you reboot the server you'll discover that you are unable to re-launch the VNC session and you'll receive a "Failed to connect to server" error message. This is because the vncserver -geometry 1280x1024 -depth 24 command we typed above is not persistent. To solve this we need to ensure that VNC is run on boot: How to run VNC on startup
At the time of writing the Synaptic Package Manager does not get installed by default in Lucid or Karmic when you install the core gnome desktop. The Synaptic Package Manager is a great tool which makes adding and removing applications a breeze. So we'll simply install it manually by typing the following two commands in a Terminal/Putty session:
sudo apt-get update
sudo apt-get install synaptic
When you now go into your server desktop via VNC you'll find the Synaptic Package Manager under the System -> Administration menu.
Still stuck? Now what you were looking for? Then head over to the Discussion Forum!