Wednesday 20 June 2012

How To Install Software On Linux (It's not that hard!)

OK, so I have had enough with people asking me how to install stuff on Linux, it's really not that difficult but it does seem to put a lot of people off the OS. I'm going to go through a few things here such as rpm, tar.gz and tar.bz2.


RPM
rpm stands for "Red hat Package Manager". Files with this extension are installed and managed with the rpm program which I will take you through now.
The rpm program not only installs the software but it checks your system has all the prerequisites. For example if you are trying to install a package called "LinuxWow" but that package requires "LinuxFTW" that you haven't installed rpm will not install "LinuxWow". However if you have "LinuxFTW" then the package will be install as it should. This can save a lot of frustration... believe me.  

before installing an rpm file it might be a good idea to check if you already have this installed, to do this run the following command:
rpm -q package_name
-q = query

The commands you would use to install, update or remove a .rpm file are as follows:

Install one or multiple rpm files
rmp -ivh packages1.rpm packages2.rpm
-i = install
-v = verbose information (additional info)
-h = Print 50 hash marks as the package archive is unpacked

Update one or multiple rpm files
rpm -Fvh packages1.rpm packages2.rpm
-F = Freshen

Remove one or multiple rpm files
rmp -e packages1.rpm packages2.rpm
-e = erase.

TAR.GZ & TAR.BZ2
tar files usually contain source code so the idea is that you compile (build) them yourself rather then relying on a program like rpm. 

I'll show you how to install these files in 3 steps:
1. First this is to list the packages in the file, this is to make sure we don't over right anything  precious on our system. We will use the 'less' command for this. The '|' can be used as an extension of a command, so we could do ' | grep "fileName"' if we wanted to grep the package for a certain file name.
tar tvzf package.tar.gz | less
or
tar tvzf package.tar.bz2 | less
-t = list, this is to list the contents of the package
-v = verbose, you know this by now
-z = this filters the package through gzip, like win-zip if you're from windows
-f = uses the package file


2. If we are happy with everything then we extract the files to a new directory, as shown below:
we make a new directory called newdir:
mkdir newdir
Enter the directory:
cd newdir
and extract the files:
tar xvzf <path>/package.tar.gz
or
tar xvzf <path>/package.tar.bz2


3. once extracted look for a file called 'install' or 'readme' these will give you the rest of the information you need. They usually tell you to run a script called 'configure', after that we run the 'make', (this will ask us to enter our root password) command and then finally the 'make install'.
./configure
make
su
(enter password)
make install


The 'readme' file may contain some other information about the configure script which may require you adding some options but the file should give you all the information you need.
It's really not that difficult to install software on a Linux machine. If you use Ubuntu like me then a simple "apt-get install package" would suffice. I hope this post makes people realise how easy it is.

2 comments:

  1. Good stuff. I started writing up a tutorial the other day about how to bundle up your own RPM file listing all dependencies and so on. I'll let you know when it's posted.

    ReplyDelete
    Replies
    1. Cheers, yeah let me know, that sounds interesting.

      Delete