Archive for the ‘Ubuntu’ Category

Ubuntu 12.04 Precise Pangolin failing to boot because of UEFI

Ubuntu 12.04 Precise Pangolin struggled to boot up after being installed on a Lenovo ThinkServer that features UEFI. Installer automatically created a FAT32 partition for UEFI, however Lenovo ThinkServer refused to boot up, complaining about no operating system being installed on that particular disk.

Amending boot mode in BIOS to “Legacy” instead of “EFI” and then proceeding with manual partitioning (e.g. root / and linux swap) during Ubuntu installation fixed the problem.

No Comments

Shrinking a dynamic Virtualbox hard disk on Ubuntu

Mount a Ubuntu Live CD and boot into it. Install zerofree

sudo apt-get install zerofree

If the package cannot be found, try enabling Multiverse repository (Software Sources).

Find out which drive you want to shrink


Run zerofree

sudo zerofree /dev/sda1

Once finished, shut down the Virtualbox machine and use Virtualbox to compact the hard disk image file

VBoxManage modifyvdi /path/to/the/image.vdi compact


No Comments

Fetching of emails from a POP3 server and serving via IMAP (Ubuntu)

One of the servers from which I download emails regularly doesn’t provide IMAP access. The obvious solution seemed to be install my own IMAP server and fetch emails from the original server via POP3.

After a brief research, I’ve decided to install Dovecot and getmail to accomplish the above.

First step was to install Dovecot:

sudo apt-get install dovecot-imapd

Then I followed instructions from Dovecot website, set the location of IMAP mail directories and configured it to use SSL connections only. I have also modified standard port in /etc/dovecot/dovecot.conf from 993 to a different one:

protocol imap {
ssl_listen = *:7777

Restarted Dovecot

sudo /etc/init.d/dovecot restart

and tested my first IMAP account using Thunderbird. As the SSL certificate I used on the server was self-signed, Thunderbird complained about it but that can be ignored and SSL certificate saved.

After that, I installed getmail:

sudo apt-get install getmail4

For each mailbox I wanted to download from a POP3 server, I defined a separate config file for getmail:

type = SimplePOP3Retriever
server = mailserver
username = user
password = pass

type = Maildir
path = ~/Maildir/

Note that emails will be saved into Maildir directory within home directory of a particular user. Maildir is also the format in which emails will be saved. This configuration works nicely with Dovecot when serving emails.

The last step was to set up a cron job to fetch emails from POP3 and save them into IMAP folder:

crontab -e
* * * * * getmail -d >> getmail.log

where “-d” means it will delete messages from the server after downloading them.

getmail can also load multiple config files at once, so if you have more then one account to fetch:

getmail -d -r configfile1 -r configfile2

No Comments

Default terminal size in Ubuntu

Too small for you?
sudo gedit /usr/share/vte/termcap/xterm
and replace :co#80:it#8:li#24:\ with say :co#180:it#8:li#30:\
That will give you 180×30

No Comments


Stumbled upon this lovely monitor today.

Conky is a free, light-weight system monitor for X, that displays any information on your desktop.

Here is a screenshot of my configuration:


To get the same:

$ sudo apt-get install conky
$ vi .conkyrc

paste the contents of this conky config:

… save the file, download and extract this archive into your home directory (cd ~) and run

$ conky

Please note that I have removed CPUs 2-4 from the config to make it more compatible with single processor systems. Full list of Conky variables.

If you wish to monitor a remote Ubuntu computer and display conky’s output on your desktop:

$ scp .conkyrc scp username@remoteserver:
$ ssh -X username@remoteserver
$ sudo apt-get install conky
$ conky

UPDATE: If your server doesn’t have Xorg installed (which most don’t), you can use {execi} to issue commands over ssh and grep the info you need. The below part of conkyrc is based on a Ubuntu Jaunty server, your distribution may vary in where some of the details are stored.
${voffset 30}
${execi 43200 ssh vds hostname} ${hr 2}
${voffset 2}${font OpenLogos:size=16}u${font}   Kernel:  ${alignr}${execi 43200 ssh vds uname -r}
${execi 43200 ssh vds less /proc/cpuinfo | head -n 5 | tail -n 1 | cut -d @ -f 2 | cut -c 2-} ${alignr}Load: ${execi 60 ssh vds uptime |cut -d , -f 4- | cut -c 17-}
${execibar 60 ssh vds bash ~/}
${execigraph 60 ssh vds bash ~/}
${font StyleBats:size=16}q${font}   Uptime: ${alignr}${execi 60 ssh vds uptime |cut -d , -f 1 | cut -c 2-}
${font StyleBats:size=16}q${font}   Users logged in: ${alignr}${execi 60 ssh vds w | head -n 1 | cut -d \  -f 7- | cut -d \, -f1}

HD ${hr 2}
${execi 600 ssh vds df -h | head -n2 | tail -n1 | cut -c 24-}
${voffset 4}${execibar 600 ssh vds df -h | head -n2 | tail -n1 | cut -c 41-42}

NETWORK ${hr 2}
${voffset 4}${font PizzaDude Bullets:size=14}N${font}   Download: ${alignr}${execi 600 ssh vds ifconfig | head -n 8 | tail -n 1 | cut -d \( -f 2 | cut -d \) -f 1}
${voffset 4}${font PizzaDude Bullets:size=14}T${font}   Upload: ${alignr}${execi 600 ssh vds ifconfig | head -n 8 | tail -n 1 | cut -d \( -f 3 | cut -d \) -f 1}
${voffset 4}${font PizzaDude Bullets:size=14}b${font}   Public IP: ${alignr}${execi 43200 ssh vds ifconfig | head -n 2 | tail -n 1 | cut -c 21- | cut -d \  -f 1}

TOP: ${hr 2}
${voffset 4}${execi 60 ssh vds ps -eo pcpu,pid,user,args | sort -k 1 -r | head -5}

Note that if you run both local and remote conky, you may need to amend conky’s position on the remote server in .conkyrc so they won’t overlap.

To start conky from a remote computer and have it displayed on yours, create this as a .sh script and run:

ssh -X username@remoteserver 'conky'

And finally, if you wish to start conky automatically after your log in, create a bash script with the following and add it into your Ubuntu start up programs:

sleep 20 && conky;

Halting it for 20 seconds prevents compiz from applying border and drop down shadows etc. to conky’s window.

No Comments

Running a script after log off in Ubuntu

Perhaps bit of a hack I but could not find another way of unmounting Samba shares automatically before my user session ends. If I do not unmount them myself, they would stay mounted after network manager has shutdown making Ubuntu hang. So to overcome this problem, I’ve done the following:

$ cd /etc/gdm/PostSession
$ sudo vi Default

add your commands before “exit 0″, for example:

sudo fusermount -u /home/juraj/shareA/
sudo fusermount -u /home/juraj/shareB/
exit 0

Save (:wq) and give it a go - restart or logoff. Tested in Ubuntu 8.10

No Comments

Ubuntu - visual tuning

Ubuntu comes with Gnome and default settings include some visual effects (provided graphic card and drivers can handle them). To get the most out of it, consider installing the following (using Synaptec or “sudo apt-get install package-name“):

This manager includes endless compiz configuration options including burning of windows on closing, Mac-like window effects and much more.

Allows to customise Gnome colours - panels, desktop, icons etc. Try these 220 Gnome colour schemes

No Comments