Friday, 2 September 2005

AutoPackage - The vendor neutral installer for Linux

When ever I decide to download and install a software on Linux, I am given the choice of a plethora of packages to download - each targeted at a particular distribution. And many times different versions of the same distributions needing different packages. For example, if I am using Fedora Core 2 and I want to download and install a software, then it will have separate packages for debian, fedora, redhat, mandrake and so on ; and I have to choose the package targeted at fedora. And if by any chance you don't have a package of the software for your distribution, you might have to download the source and compile it yourself and install it.
Two days back, I decided to download and install the Super Tux game on Linux. When I visited their site, I found that they had only one single binary package targeted at all Linux flavours which I found really surprising. I read a little bit more and came to realize that they have used autopackage to distribute their software.
What is autopackage ?
In a end users perspective, autopackage lets you install an up to date software without any hassles like dependency issues and more importantly, you don't have to choose which distro you run based on how many packages are available.
For developers, autopackage lets you create binary packages for Linux that will install on any distribution, can automatically resolve dependencies and can be installed using multiple front ends (command line, GUI etc).

Coming back to the story, I downloaded the file supertux-0.1.3.x86.package from the Super Tux game website which was a 6.7MB download. Then according to their directions, I set the executable bit for the software as follows :

$ chmod ugo+x supertux-0.1.3.x86.package

Note: You can also do this in KDE by right clicking the file, choosing properties and then clicking the permissions tab and checking the "is executable" checkbox.

Now I executed the file by double clicking on it. You could also execute the file in command line by entering the command :

$ bash supertux-0.1.3.x86.package

At the time of execution, I did not have autopackage installed on my system. So it offered to download and install the autopackage software from the net. This is the message I got:

autopackage for "SuperTux platform game"
The installation of this software requires some additional support code to be installed.


A] If the support code is found in a local directory, it will be used.

The file containing the support code will be called:
"autopackage.tar.bz2"
or

B] If there is an active Internet connection, the support code will be

downloaded from:
"http://autopackage.org/latest/autopackage.tar.bz2"


Proxy users should ensure the http_proxy environment variable is
set, otherwise the download may fail.


Selection B --> OK to download and install support code now? (Y/n): Y


I typed 'Y' and it automatically downloaded the autopackage software (a small download) and installed it on my system. During installing, it gave me the choice of installing it system wide which I accepted for which I had to supply the root password.

After this the installation of the game started. Here also I was asked for the root password to install it system wide. And the installation completed without a hitch.





Things to remember
1) Autopackage installs the software by default in /usr directory. If you want to install it elsewhere, you have to modify the file /etc/autopackage/config and change the autopackage_prefix section to point to another location.

# FILE: /etc/autopackage/config
...
autopackage_prefix="/usr/local"
...

Or you can also use the --prefix switch while installing using command line.

2) Autopackage uses the package program to manage (install, uninstall) the softwares. For example, to uninstall the Super Tux game, I just run the following command by logging in as root :

# package remove supertux

It is as simple as that.

Advantages of Autopackage
  • Supports automatic dependency resolution like in apt and emerge.
  • One common package for all known Linux/Unix distributions.
  • Double click and install softwares like in Windows OS.
  • Choice of GUI based and command line method of installation.
Drawbacks of Autopackage
  • If you install using autopackage, it will not update the RPM database.
  • There is no package signing.
  • Autopackage cannot be used to build Linux distributions.
  • Is not cross-platform. Supports only x86 and x86-64 (might change at a future date).


The Super Tux game screenshot

Thursday, 1 September 2005

Scribus - The free DTP software for Linux

Scribus is a robust desktop publishing (DTP) GPLed software for Linux and other Unixes.

What is Desktop Publishing (DTP)

Desktop Publishing (DTP) also known as prepress publishing combines a personal computer and WYSIWYG page layout software to create publication documents on a computer for either large scale publishing or small scale local multifunction peripheral output and distribution.

The term "desktop publishing" is commonly used to describe page layout skills. However, the skills and software are not limited to paper and book publishing. The same skills and software are often used to create graphics for point of sale displays, promotional items, trade show exhibits, retail package designs and outdoor signs.

A DTP software is a page layout software which gives users great flexibility in placing objects like images, text, and logos in the exact place where you want them. A DTP is commonly used in advertising and publishing firms to create print ready documents, flyer's, CD covers, advertisements, greeting cards, company brochures, newsletters and posters.

All newspapers around the world use DTP software to layout the news matter before it is send to print. Using a DTP software you can create files which print easily at your commercial printer (printing press). The industry leaders in DTP software are Adobe (Pagemaker) and Corel (Draw) which are commercial ventures and which support only windows platform.

But now Linux has got its own DTP software in Scribus which rivals these market leaders in the features it exhibits.

Fig 1: Cover page of a magazine designed in Scribus.


Fig 2 :The content of the magazine which displays the images and the text in a beautiful manner.
Fig 3: Easily create interactive PDF forms using scribus.

Scribus supports professional publishing features such as CMYK colour (Cyan,Magenta, Yellow, blacK) separations ,ICC colour management and embedding ICC profiles in PDF documents for accurate screen to print color, which are a must in any DTP software. Other features include importing and exporting to PDF, EPS (Encapsulated PostScript), SVG (Scalable Vector Graphics) and more common formats like text, images and so on. There is a great set of tutorials for those interested in using Scribus at docs.scribus.net.

Wednesday, 31 August 2005

Vim - The powerful simple editor

You select any Linux/Unix OS distribution; from the spartan linux which fits on a floppy to the industry heavy weights like redhat and suse; you are guaranteed to find the vi editor. So it is really worth ones time to learn how to use this powerful but simple editor. Vim is the modern version of the vi editor. Learning to use vim (vi) contains an initial learning curve. But the power it gives the user to accomplish complex text manipulation with just a few keystrokes makes the trouble taken to learn worth it.

Here I will explain a few commonly used commands in Vim. Vim (vi) is an editor with modes of operation. There are three modes of operation in vim. They are as follows :
Read more »

Who owns which port ?

Linux contains a lot of command line tools which make the job of a network administrator easier. One of them is netstat. Netstat is a multi-purpose network informantion tool. Using netstat, you can find which port is used by which process or user by using the following command:

# netstat -an | more
There is a utility called fuser which also tells you which user and process owns a port. For example, if you want to find who owns port 631, you execute the following command:

$ fuser -v -n tcp 631
Note : Ports below 1024 are reserved for common services , and only root can use them. Standard port numbers can be found in /etc/services file. The rest of the over 65K ports can be used by normal users or processes.

Convert MS Word Files to Other formats using Abiword

Abiword is a word processor which can be used as an alternative to popular commercial counterparts. It comes installed by default on most Linux distributions.

Did you know that you can convert from one file type to another in the command line using Abiword ? This is how it is done. Read more »

Tuesday, 30 August 2005

Bash Shell Shortcuts

Bash, which is the default shell in Linux contains a whole lot of key bindings which makes it really easy to use . The most commonly used shortcuts are listed below :

____________CTRL Key Bound_____________
Ctrl + a - Jump to the start of the line
Ctrl + b - Move back a char
Ctrl + c - Terminate the command
Ctrl + d - Delete from under the cursor
Ctrl + e - Jump to the end of the line
Ctrl + f - Move forward a char
Ctrl + k - Delete to EOL
Ctrl + l - Clear the screen
Ctrl + r - Search the history backwards
Ctrl + R - Search the history backwards with multi occurrence
Ctrl + u - Delete backward from cursor
Ctrl + xx - Move between EOL and current cursor position
Ctrl + x @ - Show possible hostname completions
Ctrl + z - Suspend/ Stop the command
____________ALT Key Bound___________
Alt + < - Move to the first line in the history
Alt + > - Move to the last line in the history
Alt + ? - Show current completion list
Alt + * - Insert all possible completions
Alt + / - Attempt to complete filename
Alt + . - Yank last argument to previous command
Alt + b - Move backward
Alt + c - Capitalize the word
Alt + d - Delete word
Alt + f - Move forward
Alt + l - Make word lowercase
Alt + n - Search the history forwards non-incremental
Alt + p - Search the history backwards non-incremental
Alt + r - Recall command
Alt + t - Move words around
Alt + u - Make word uppercase
Alt + back-space - Delete backward from cursor

----------------More Special Keybindings-------------------

Here "2T" means Press TAB twice

$ 2T - All available commands(common)
$ (string)2T - All available commands starting with (string)
$ /2T - Entire directory structure including Hidden one
$ 2T - Only Sub Dirs inside including Hidden one
$ *2T - Only Sub Dirs inside without Hidden one
$ ~2T - All Present Users on system from "/etc/passwd"
$ $2T - All Sys variables
$ @2T - Entries from "/etc/hosts"
$ =2T - Output like ls or dir

Tuesday, 23 August 2005

Installing and Configuring Java in Linux

Java is a revolutionary language which was invented by James Gosling at Sun Microsystems. The most endearing thing about Java is its platform independence - which means you can literally compile it on one platform and then run it on any other platform be it Sparc, Intel, Motorola or PowerPC architecture running any of the OSes (Windows, OSX, Linux...). Recently I had the opportunity to work in Java/J2EE technology. And naturally I wanted to do programming in Linux instead of windows (basically because I am more productive and comfortable working in Linux than windows). Here I will detail the steps I took to install and configure Sun's JDK 1.5.0 on Linux.
  • I Download the latest JDK (Java Development Kit - latest is ver 1.5.0) for Linux from Sun's java site. It was a zip file which, when I unpacked into my home directory, created a directory named 'jdk1.5.0'.
  • Then I logged in as 'root' and moved the just created 'jdk1.5.0' directory into the /opt directory.
  • Now again logging in as normal user, I appended the following lines to my .bashrc file.
#FILE .bashrc
...
JAVA_HOME=/opt/jdk1.5.0
export JAVA_HOME

export PATH=$PATH:/opt/jdk1.5.0/bin

CLASSPATH=/opt/jdk1.5.0/lib/tools.jar: \ /opt/jdk1.5.0/lib/dt.jar
export CLASSPATH
...

As you can see in the above listing, I have set the JAVA_HOME variable to point to my Java installation directory. This is needed because some application servers like JBoss will be checking if Java is installed on your system using JAVA_HOME variable. And I have also modified the PATH variable to point to the Java bin directory. I have set a third variable CLASSPATH which points to the libraries needed to compile Java programs. This is needed because when you compile your Java programs in the command line, the compiler needs to know where the libraries are located. This it achieves by reading the CLASSPATH variable. Don't forget to export JAVA_HOME, PATH and CLASSPATH. Once you have edited your .bashrc file, open a terminal and execute the command to make the bash shell to re-read the contents of the .bashrc file as follows:
$ source ~/.bashrc
Now you can compile and execute Java programs in Linux just like you do in windows.

MySQL integration in your Java Programs
Java has excellent support and integration with all major databases through the JDBC API. Since MySQL - a time tested robust database - comes bundled by default with most Linux distributions, any Java programmer on the Linux platform need not look at alternative databases. But to program in Java using JDBC to connect to MySQL database, you have to download and install the MySQL-Java driver. Below I list the steps needed to configure Java to work with MySQL.
  • First go to the MySQL website and download the MySQL ConnectorJ driver for Java file (Size: 6.6 MB). When I downloaded, the latest version was 3.1.10. (mysql-connector-java-3.1.10.tgz ), which might have changed by now. This is a gzipped tape archive. So unpack it into a directory of your choice as follows:
    $ tar -xvzf mysql-connector-java-3.1.10.tgz
    This will unpack it into a new directory by name mysql-connector-java-3.1.10.
  • Now login as root and move the whole directory into the /opt directory.
  • Next logout as root and login as normal user and modify CLASSPATH in your .bashrc file as follows:
# FILE .bashrc
...
CLASSPATH=/opt/jdk1.5.0/lib/tools.jar:/opt/jdk1.5.0/lib/dt.jar \\ :/opt/mysql-connector-java-3.1.10/ \ mysql-connector-java-3.1.10-bin.jar
export CLASSPATH
...

That is it. Now you can write JDBC code in Java to connect to MySQL just like you do it in windows or any other platform. Below I have written the section where you need to enter MySQL specific code :

# Program Snippet
...
try{
String driver = "com.mysql.jdbc.Driver";
Class.forName(driver);
String url = "jdbc:mysql://localhost:3306/mydatabasename";
Connection con = DriverManager.getConnection(url,"username","password");
// The rest of the code is common for all databases.
}
...