Tag Archives: linux

Comparison of Linux compression commands

Recently I had to back up a virtual machine server I had in the US before decommissioning it. As I had a lot of large folders I realised that compressing them would take some time. Being the lazy administrator that I am I took some time out to find the fastest compression command on Linux before I began my backup process.

Here is what I found for a 117Mb folder.


dhruba : /backup # time tar -cjf root.home.tbz /root/
real    0m34.600s
user    0m34.040s
sys     0m0.357s


dhruba : /backup # time tar -czf root.home.tgz /root/
real    0m6.255s
user    0m5.672s
sys     0m0.415s


dhruba : /backup # time tar --use-compress-program=lzop -cf root.home.tlzo /root/
real    0m2.624s
user    0m2.061s
sys     0m0.383s

The file sizes for the three commands were as follows.

dhruba : /backup # ls -lShr
-rw-r--r-- 1 root root 81M Dec 14 20:46 root.home.tbz
-rw-r--r-- 1 root root 83M Dec 14 20:43 root.home.tgz
-rw-r--r-- 1 root root 88M Dec 14 20:43 root.home.tlzo

As you can see lzop has by the fastest compression size but the largest compressed file size. If, like me, this is the trade-off you are looking for then lzop is your answer.

Installing Java, Scala and Vim support on Linux

Here’s a quick guide on how to install Scala on linux (in my case Ubuntu 9.04). A prerequisite obviously is to have the sun jdk installed and properly integrated into your linux environment. For completeness I detail how I normally tend to set up the jdk on my linux environment before moving onto the installation of Scala. Note that here /opt/ is used as the destination directory for installation as that is what I prefer but this can be any directory that you have write permissions on. You’ll also note that I don’t use any automated linux installation tool like apt-get and that is deliberate as the following methods of installation allow you not only complete control of installation of the packages but greater flexibility when upgrading. Finally we’ll look at adding Scala support to my favourite command line editor – Vim.

Install Sun JDK

Download the latest Sun JDK (JDK 6 Update 14 at time of writing).

Make executable and extract.

$ chmod u+x jdk-6u14-linux-i586.bin
$ ./jdk-6u14-linux-i586.bin


$ mv jdk1.6.0_14/ /opt/


$ cd /opt/
$ ln -s jdk1.6.0_14/ java

In /etc/profile set JAVA_HOME variable and add JDK bin directory to system path.

export JAVA_HOME="/opt/java"
export PATH="${JAVA_HOME}/bin:${PATH}"

Import your newly modified profile

$ source /etc/profile

Test Java.

$ java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
$ javac -version
javac 1.6.0_14

Install Scala

Download the latest Scala (2.7.5 at time of writing).


$ tar -xvzf scala-2.7.5.final.tgz


$ mv scala-2.7.5.final/ /opt/


$ cd /opt/
$ ln -s scala-2.7.5.final/ scala

In /etc/profile set SCALA_HOME environment variable and add the Scala bin directory to your system path.

export SCALA_HOME="/opt/scala"
export PATH="${SCALA_HOME}/bin:${JAVA_HOME}/bin:${PATH}"

Import your newly modified profile

$ source /etc/profile

Test Scala.

$ scala
Welcome to Scala version 2.7.5.final (Java HotSpot(TM) Server VM, Java 1.6.0_14).
Type in expressions to have them evaluated.
Type :help for more information.

scala> 1+1
res0: Int = 2

scala> println("Hello World!")
Hello World!

Add Scala support into Vim

If you’re like me and you can’t live without Vim or you just need Vim to get started with Scala prior to moving onto your favourite IDE then here’s how you can add Scala support into Vim.

Create required vim directories.

$ mkdir -pv ~/.vim/ftdetect
$ mkdir -pv ~/.vim/indent
$ mkdir -pv ~/.vim/syntax

Download Scala support into vim directories.

$ wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/export/18260/scala-tool-support/trunk/src/vim/ftdetect/scala.vim -O ~/.vim/ftdetect/scala.vim
$ wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/export/18260/scala-tool-support/trunk/src/vim/indent/scala.vim -O ~/.vim/indent/scala.vim
$ wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/export/18260/scala-tool-support/trunk/src/vim/syntax/scala.vim -O ~/.vim/syntax/scala.vim

Create a basic ~/.vimrc configuration if you haven’t got one.

set nocompatible
set nu  
syntax on
filetype indent on
set autoindent
set ic
set hls 
set lbr 
colorscheme delek

Try editing a Scala file. It should appear in colour.

1 for {i <- 1 to 10
2 j <- 1 to 10}
3 println(i*j)

Rejoice. Get coffee. Develop. Lose sleep. The usual lifecycle.

Acknowledgements (Scala Vim support, Vim colorised output).

K(u)buntu 8.10 released

I’m a little late in reporting this but on 30 Oct (3 days ago) Ubuntu and Kubuntu 8.10 were released. Currently I use Debian for server and Kubuntu for desktop. Previously I was a big fan of Gentoo and prior to that I tried every distribution under the sun while at university. Kubuntu 8.10, it seems, includes KDE4 which I really hope has stabilised sufficiently to become the default distributed version and reached the 4.1 version. The last remix cd was, from what I’ve heard, unusable.

While previously Ubuntu was a little new on the scene and was being treated with skepticism as yet another operating system based on Debian it has now matured into a stable, trusted and widely adopted linux distribution and for me, as with most people, it simply works and stays out of the way allowing me to get my work done – the work being in my case not only being my primary operating system but also being my preferred environment for Java development. A dual boot between Vista and Linux is of course always necessary – Windows being for games, IE and other Windows specific requirements.