Posts Tagged ubuntu server

Use VNC Viewer remotely control Ubuntu Desktop

Ubuntu server usually does not have a Desktop application and does not have monitor either. However, Ubuntu desktop can be installed on Ubuntu server. There are several things you have to solve before we can connect to Ubuntu Desktop remotely.

1 Install Ubuntu Desktop

Install Ubuntu Desktop to Ubuntu Server is simple and easy.

apt-get update
apt-get install ubuntu-desktop

Once it started, you have to wait a while for all files downloaded and installed.

2 Solution for internet connection

If the Ubuntu server uses fixed IP address, most likely the Web Browser in Ubuntu Desktop does not work. How to solve the problem? The cause is the Network Manager changed /etc/resolv.conf file. There were no nameservers in that file. What you can do is to manually add a couple nameservers to the file.


3 Solution for starting Desktop without a monitor

Once everything installed and uprunning normally. You may want to unplug the monitor. Unfortunately, once the monitor is unplugged, the Desktop will not start automatically. Solution is simple. Just use nano or your favorite editor to edit /etc/X11/xorg.conf file. Replace its content to the following. You can change the screen resolution based on your situation. Here is “1280×1024”.

Section "Device"
Identifier "VNC Device"
Driver "vesa"

Section "Screen"
Identifier "VNC Screen"
Device "VNC Device"
Monitor "VNC Monitor"
SubSection "Display"
Modes "1280x1024"

Section "Monitor"
Identifier "VNC Monitor"
HorizSync 30-70
VertRefresh 50-75

4 Config VNC Server

Use “System” -> “Preferences” -> “Remote Desktop” to config the VNC server. For sharing, you can choose what level of the sharing you want to give to your system users. For security, you also need choose the right level for your situation. Notification area option is easy. Once the setting is down, your VNC server is ready whenever the system is rebooted. Do not forget to disable Desktop Effects by the following command:

metacity --replace

Execute it in a terminal window.

5 VNC viewer

This is the easier step. In Windows environment, you can download “TightVNC Viewer”. It is free and easy to use.

The nice thing is you can use iPod/iPhone to connect to your server. The app called Mocha VNC Lite. I tested it both for Widnows VNC server and Linux VNC server. It works nicely for me.

If you want to learn more please a great post at .

Update on Jan 24, 2011

The above solution works for Ubuntu 9.10. After I upgraded my system to Ubuntu 10.04 TLS. I found the solution no long works. After several hours googling around and tried out different suggestions. No success until I found a post at

To make this work for Ubuntu 10.04 is easy. After you finish the above settings, then, edited the grub file:

nano /etc/default/grub

This will open the grub file. Now find the line that says GRUB_CMDLINE_LINUX and add “nomodeset”. You’ll have to end up with something like this:


Now, update the grub from terminal with update-grub otherwise the Ubuntu will be loaded without graphical interface at all. Restart your machine. Now you can use your desktop without a monitor.


Tags: , , , , , , , , , , , , ,

Use GD library in php5 in Ubuntu server v10.04

After the new Ubuntu server 10.04 were installed, I tested my web applications. One of the web applications use Securimage from However, no image was shown up. I followed the suggestion from Securimage and put the following command in securimage_show.php:

ini_set('display_errors', 'on'); error_reporting(E_ALL);

After browse the following page: A fatal error occurs. It says that imagecreatetruecolor() could be found. I searched the and find this function is part of GD library. This means that something related to GD library was wrong.

I created a simple php file call phptest.php, which includes the following statement.

<?php phpinfo() ?>

Browse this page in a browser, it uncovered that I do not have GD library support in PHP5 installation. The GD Graphics Library for dynamically manipulating images. We usually have to compile PHP with the GD library of image functions for this to work.

However, Ubuntu (and Debian) comes with package called php5-gd. Just type following commands to install this module and restart Apache2.

# apt-get install php5-gd
# /etc/init.d/apache2 restart

I found this trick at Thanks for sharing this.

Hooray, it works now. That took me a couple of hours to find the solution. It is tough to configure a new server.


Tags: , , , , , , ,

Use power button to shutdown ubuntu server

Recently I setup a server machine with Ubuntu server v10.04. During the setting up process, I could not use power button to shutdown the machine. Since the machine does not have monitor connected, I have to log in from other machines and ran shutdown command manually. It was not very convenient. I searched the internet and found a solution. Because the power button produces an ACPI event, we have to have ACPI enabled. I checked my /etc directory, there is no directory called acpi. So I installed apci manually by the following command.

$ sudo apt-get install acpid

After this was done, I can use the power button to shutdown the machine.


Tags: , , , ,

Add USB hard drives to Ubuntu server

I have a Ubuntu file server with limited storage space. I want to add a USB hard drive to extend its storage space. I did it in the following step.

  1. Plug in the USB hard drive to the Ubuntu server

    After I plugged the USB hard drive, the server was rebooted. Then I check the device table to find out what is the name of the new drive. I specifically use fdisk to find more information. The following is a snap shot of fdisk output.

    # fdisk -l
    Disk /dev/sda: 160.0 GB, 160041885696 bytes
    255 heads, 63 sectors/track, 19457 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x7e29f58f
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1       19083   153284166   83  Linux
    /dev/sda2           19084       19457     3004155    5  Extended
    /dev/sda5           19084       19457     3004123+  82  Linux swap / Solaris
    Disk /dev/sdc: 160.0 GB, 160041885696 bytes
    255 heads, 63 sectors/track, 19457 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x93026feb
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1               1       19457   156288321   83  Linux
  2. Create new partitions and format them

    Suppose the USB drive is /dev/sdc, you can use fdisk to repartition the drive and format the new partitions. The following is a few command for this purpose.

    #fdisk /dev/sdc
    The number of cylinders for this disk is set to 19457.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
       (e.g., DOS FDISK, OS/2 FDISK)
    Command (m for help): p
    Disk /dev/sdc: 160.0 GB, 160041885696 bytes
    255 heads, 63 sectors/track, 19457 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x93026feb
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1               1       19457   156288321   83  Linux
    Command (m for help): m
    Command action
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition
       l   list known partition types
       m   print this menu
       n   add a new partition
       o   create a new empty DOS partition table
       p   print the partition table
       q   quit without saving changes
       s   create a new empty Sun disklabel
       t   change a partition's system id
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit
       x   extra functionality (experts only)
    Command (m for help):

    You can use d to delete the old partition and n to create new partition. Use w to write the new partition table to disk once you are done. Then you can use mkfs.ext3 to create ext3 format partition.

    # mkfs.ext3 /dev/sdc1
  3. Create entries in fstab to mount the new partition at boot time

    First you have to use “blkid” or “ls /dev/disk/by-uuid” find the uuid of the new partitions.

    # blkid
    /dev/sda1: UUID="05647485-6314-4603-aa7d-f1f2bf1a7b63" TYPE="ext3"
    /dev/sdc1: UUID="5eed4bd1-258f-4441-b28c-3e8d9988e656" TYPE="ext3" SEC_TYPE="ext2"
    /dev/sda5: TYPE="swap" UUID="efb89cfb-53e9-4202-8496-4f4b9eff6295"
    /dev/sdb1: UUID="5eed4bd1-258f-4441-b28c-3e8d9988e656" SEC_TYPE="ext2" TYPE="ext3"

    In this example, our new partition UUID is “5eed4bd1-258f-4441-b28c-3e8d9988e656”. We can go ahead to add this to /etc/fstab.

    UUID=5eed4bd1-258f-4441-b28c-3e8d9988e656  /extrastorage    ext3    relatime,errors=remount-ro  0       0

    Now you can run the following command to refresh your file system.

    # mount -a

    Check if the new USB partition is mounted and usable by “df”.

    root@citrice:/dev/disk# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda1            150877984  44458352  98755424  32% /
    tmpfs                  1032176         0   1032176   0% /lib/init/rw
    varrun                 1032176       844   1031332   1% /var/run
    varlock                1032176         0   1032176   0% /var/lock
    udev                   1032176      2748   1029428   1% /dev
    tmpfs                  1032176         0   1032176   0% /dev/shm
    lrm                    1032176      2004   1030172   1% /lib/modules/2.6.27-14-generic/volatile
    /dev/sdc1            153834852 118941832  27078604  82% /extastorage ###### yes it is here
    tmpfs                  1032176      2204   1029972   1% /lib/modules/2.6.27-15-generic/volatile
    1. Now your new USB hard drive is integrated into your Ubuntu server seamlessly. You can use it as you want.


      Tags: , , , , , , ,

Use munin to monitor Ubuntu server performance

munin is a light weight server monitoring tool. After I read the following two articles I decided to give a try. Here are the links for the articles:
Monitor Servers and Clients using Munin in Ubuntu
Monitoring systems with munin

The setup is a piece of cake. I have a little bit confusion when I setup allow IP at munin-node cconfig file. But I figured out after reading the articles. The IP should be the munin server’s IP address. It means that allow munin server at that IP to survey the munin client.

Another place I was confused was to start munin server. I checked /etc/crontab and did not see anything related to munin. I manually added an entry based an article describing how to use munin in red-hat system. It was not right on Debian/Ubuntu. I learned that there is cron job was put in /etc/cron.d for munin. Yes, indeed there is one. I waited a while and did not see any update on the web page. I decided to manually execute the munin once. I used the following command:

/usr/bin/munin-cron –force-root

If you change the htmldir, please remember to change the owner and group of the new directory and its subdir to munin:munin. Otherwise you will get some error message like “Lock already exists: /var/run/munin/munin-graph.lock. Dying.”. The command is:

chown -R munin:munin

Read details about AWFFULL http log analysis tool at Use AWFFULL to analyze website log files.


Tags: , , , , , ,