Magento Expert Forum - Improve your Magento experience

onet connect
Results 1 to 2 of 2

Install VNC server(Remote Desktop) on Ubuntu Server 12.04

  1. #1
    Junior Member rocker's Avatar
    Join Date
    Mar 2013
    Thanked 11 Times in 9 Posts

    Thumbs up Install VNC server(Remote Desktop) on Ubuntu Server 12.04

    Method 1

    Install vncServer in Ububtu 12.04 server to create a virtual desktop on another computer

    These are the instructions for installing vncserver on Ubuntu 12.04 server edition. They may also work on Desktop, but I haven't tested them on it.

    First install ubuntu 12.04 server

    Install Amahi using the instructions provided elsewhere on the wiki.

    After reboot go to your HDA and login, then go to apps and install OpenSSH and webmin using the links in your HDA.


    sudo reboot now -h​
    From here on I used vim but you can use any editor you are comfortable with just replace vim with your choice.

    A quick and short tutorial on vim:

    Move the cursor to where you want to edit then press i Edit as needed, when finished press esc then :wq to save your changes If you make a mistake press :q! you exit without saving changes, then start again.

    A cheat sheet for vim commands can be found here:

    Now go to another machine, I used windows 7, and download putty.

    From here on it will be all copy and paste in putty. (makes it easy)

    Start putty

    In Host Name (or IP address) enter the static ip address of your server, you can find it in your control panel on For example:

    DO NOT enter http://

    Leave the Port at 22

    If you want you can save it for easier later use by adding a name in Saved Sessions and clicking Save

    Now click Yes

    A terminal will open and another window asking you to confirm the server click okay

    Enter your ubuntu username and password when asked

    You will be connected to your server.

    all the following commands can be copied and pasted into putty with a simple right click.

    Copy and paste

    sudo apt-get update​
    when complete

    sudo aptitude safe-upgrade​
    reboot server type

    sudo reboot now -h​

    A: Install Gnome basic desktop.

    log in with putty again from your windows machine.

    I installed the server version of Ubuntu, so to be able to have a desk top when I log into vnc I need to install a few things in Ubuntu.

    First off we need to install the Gnome components for our virtual desktop. Type or copy and paste:

    sudo apt-get install gnome-core​
    when prompted type Y and then press Enter. This will install the gnome desktop components.


    sudo reboot now -h​
    To keep the desktop and login window from opening in Ubuntu everytime it starts we want to mask out the few lines which start the service.

    sudo vim /etc/init/gdm.conf​
    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 protected]>"
                #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 [016]
                emits login-session-start​
    esc :wq to save the changes or :q! to start over. Now the desktop and login won't start in Ubuntu.

    NOTE: This only installs a basic desktop, if you want to be able to use programs from your virtual desktop, network manager, media players, office, etc, they will need to be installed after vnc server is installed.


    sudo reboot now -h​

    B: We need to install VNC server to be able to interact with the gnome components for the desktop.

    sudo apt-get install vnc4server

    When prompted type Y and press Enter. This will install VNC Server which is required for running a virtual desktop on another machine.

    Next type:

    You'll then be prompted to create and verify a new password.

    We now need to kill the session we just created and make change the startup script for VNCServer to make it work properly.

    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:

    sudo vim .vnc/xstartup​
    Change it to look like this:
                # Uncomment the following two lines for normal desktop:
                unset SESSION_MANAGER
                #exec /etc/X11/xinit/xinitrc
                gnome-session --session=gnome-classic &
                [ -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 editing the file press the Esc key once and type :wq

    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 1680x1050​
    where 1280x1024 is the resolution of your DESKTOP COMPUTER.

    Download and install TightVNC onto your desktop computer.

    When you launch it type your hda server name followed by a colon and the number 1 (this is the name you gave it when you installed Ubuntu)for example: Ubuntu-1204:1

    Or use it's static ip address and :1 eg: in the VNCServer box.

    Then click Connect, enter the password you created when you typed after installing vncserver.

    You now see the desktop screen.

    C: Write a script to launch VNC

    A script is basically a file containing a list of commands which will be executed each time you run it. I put all my scripts in a directory below my "home" folder in a folder called scripts.

    So, from a Putty session:

    cd /home/xxxx​

    where xxxx is your Ubuntu username. This command switches us into that directory.

    Next we'll create a folder called MyScripts below your home folder. So type:

    mkdir scripts​

    Switch into the folder we've just created type:

    cd scripts
    Next type:

    This will create a new file called and open it for editing.

    Press the i key once and copy and paste the following contents:

                echo "JOB RUN AT $(date)"
                echo "============================"
                echo ""
                /usr/bin/vncserver -geometry 1680x1050​
    NOTE: change the 1680x1050 to match the screen resolution of your Desktop computer

    Press the ESC key once and type :wq and press Enter to save.

    Next we need to make the file executable so, assuming you called your script then you'd type:

    chmod a+x​
    Test the script by typing the following:

    vncserver -kill :1​
    To make sure vncserver isn't running, then:

    A new vnc session should start.

    D: Create a cron job in webmin to run the script on boot

    Stop vncserver

                ​vncserver -kill :1​
    Now open your browser and go to your HDA and click on the webmin app you already installed, click continue to this website at the cert warning.

    Enter user and password as required.

    Within Webmin click on System and then Scheduled Cron Jobs in the left column. Then click the Create a new scheduled cron job option at the top of the screen that opens.

    Click the button next to the Execute cron job as and choose the username you created when you installed Ubuntu. Hint: your username appears in a Putty/Terminal session prompt. eg. [email protected]

    Type or paste the name of your script including the full path

    /home/xxxx/scripts/ >/dev/null​
    into the Command box, replacing xxxx with your own usernam. The ">/dev/null" parameter will discard any output the script may produce.

    Enter a suitable description in the Description field.

    In the When to Execute - Simple schedule drop-down list choose When system boots then click the Create button at the bottom of the screen.

    It should look like this:

    First test that you've set the job up correctly within Webmin. You can do this by clicking on the job you've just created from the long list of cron jobs (not checking the box but clicking on the name). In the new window that opens click the Run Now button at the bottom of the screen. You should see a message similar to the one you saw when you tested it from a Putty/Terminal session.

    Now let's check the script works on boot. So from the System -> Bootup and Shutdown menu within Webmin scroll down to the bottom of the screen and click the Reboot System button. Alternatively type

    sudo reboot now -h​
    in a Putty/Terminal session.

    After reboot go to your Windows machin and open Tight VNC Viewer and connect to your ubuntu virtual desktop. VNC Server now starts automatically on boot.

    That's it you should now have vnc server start on boot and a virtual desktop for your server on another machine.

    Most of this information was obtained from:

    View more threads in the same category:

  2. #2
    Junior Member jacobwallace's Avatar
    Join Date
    Nov 2014
    Thanked 0 Times in 0 Posts


    Such a very helpful topic.

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts