Administer Ubuntu Server Trusty Tahr 14.04LTS using VNC
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 also tested on Quantal Quetzal 12.10, Precise Pangolin 12.04LTS, Lucid Lynx 10.04LTS, Karmic Koala 9.10, 9.04 Jaunty, and 8.10 Intrepid.
To perform the installation of VNC you can either type the following commands into 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.
Install the Gnome components
First off we need to install the 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 basic gnome desktop components.
Install a Virtual Desktop using VNC
Now we've installed the gnome 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:
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 and/or a grey screen with a Terminal Session, depending on the Ubuntu version. 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 open up the file we need to edit:
IMPORTANT: The modifications we need to make to this file depend on the version of Ubuntu we're using so make sure you follow the correct section:
So, we've unmasked the unset SESSION_MANAGER line and masked out all the rest. We've then added the last 3 lines.
When you're done editing the .vnc/xstartup file for your particular version of Ubuntu press the [Esc] key once and type the following:
This should save the changes and bring you back to the command line. If you make a mistake editing the file then issue :q! instead of :wq to abort your changes.
Next type the following command to create the VNC Session once more:
vncserver -geometry 1920x1080
where 1920x1080 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. Note: For versions of Ubuntu prior to Precise Pangolin 12.04LTS add a -depth 24 argument so the command should read vncserver -geometry 1920x1080 -depth 24
Next, download and install TightVNC onto your desktop computer. When you launch it type the "Desktop Name" in the Remote Host box. See the DOS-type screenshot above for your "Desktop Name". So, in my case I'd type MyMediaServer:1 in the Remote Host: box. You can alternatively use the IP address of the server. So it'd be something like xxx.xxx.xxx.xxx:1. See below.
then click Connect, enter the password you created when you typed the vncserver command the first time round and you should then see a screen like this (Note that on Trusty Tahr 14.04LTS, Precise Pangolin 12.04LTS and Quantal Quetzal 12.10 the screen is blue/green and that error message doesn't appear):
Click the Delete button on the error message which is displayed and you now have a nice shiny desktop view onto your server!
Some keys do not work as expected - Trusty Tahr 14.04LTS
For some reason when using the Terminal in 14.04 the s & h keys are assigned as shortcut keys. This can be annoying when, for example, you're trying to do something as sudo, since as soon as you type s it pops up the Applications Menu. You can fix this annoyance quite simply as follows:
From within your new VNC session select the Applications menu then choose System Tools and then dconf Editor.
From the menus on the left-hand side drill down as follows:
org -> gnome -> desktop -> wm and then finally keybindings
Once you're there we need to make changes to the Value column on the right hand side. So, firstly scroll down to the minimize option and click on it to select it. Then click on the Value cell next to it which currently reads ['<Super>h'] and change it to  and press [Enter].
Now scroll to the panel-main-menu and do the same as above, changing the Value to .
NOTE: You may want to do the same for ALL keybindings which contain the word <Super>.
Then close the window. Now switch back to your Putty session and kill the session and relaunch it:
vncserver -kill :1
vncserver -geometry 1920x1080
obviously substituting 1920x1080 for your own values. Now the s & h keys should work as expected.
Incase you're wondering how what we've just installed differs to simply installing the full blown Desktop version of Ubuntu try connecting 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 1920x1080 -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
The Synaptic Package Manager is not installed by default
At the time of writing the Synaptic Package Manager does not get installed by default 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 Applications -> System Tools -> Administration menu.
However, at the time of writing it does not launch via the menu. So, you have to start it manually using the following command in a Terminal (Applications->Accessories->Terminal) in the VNC Session:
How to prevent Gnome starting on the server on boot
On Ubuntu versions 10.10 (Maverick Meerkat), 11.04 (Natty Narwhal), 11.10 (Oneiric Ocelot), 12.04 LTS (Precise Pangolin) & 14.04LTS (Trusty Tahr) gnome is automatically started on boot once the above instructions have been followed. So, if you connect a monitor to your server after booting it you will see the GUI sitting there waiting for you to log in. You can prevent this happening by carrying out the following tweak:
So, in Putty or in a Terminal Session issue the following command to open up the relevant script:
sudo vim /etc/init/gdm.conf
Press the [Insert] key to switch into INSERT mode and you want to mask out (using a #) the few lines which start the service ie. start on ((filesystem.... so the first few lines of the script should look like this once you've edited it:
# gdm - GNOME Display Manager # # The display manager service manages the X servers running on the # system, providing login and auto-login services
description "GNOME Display Manager" author "William Jon McCann <email@example.com>"
#start on ((filesystem # and runlevel [!06] # and started dbus # and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1 # or stopped udev-fallback-graphics)) # or runlevel PREVLEVEL=S)
stop on runlevel 
Save your changes then reboot the server and that log-in screen should no longer appear.
Still stuck? Not what you were looking for? Then head over to the Discussion Forum