.CO.NR Free Domain KAMAL KUMAR: Installing Software in GNU/Linux

Search This Blog

Monday, October 26, 2009

Installing Software in GNU/Linux

Introduction
For the benifit of people new to Linux, I have written a generic explaination of howto install software in Linux. Note that some software may have specific installation proceedures, this HOWTO is not a substitute for reading the offical installation documentation

This HOWTO covers the following topics:
  • Compiling and Installing software from source
  • Installing RPM's using the Redhat Package Manager
  • Installing using Debian's apt-get
  • Installing mandrake things
  • Installing with fedora / yum
  • Installing slackware packages
  • Installing software using Gentoo EMerge
  • Installing binary files (.BIN/.SH)
  • Installing .package Files (AutoPackage)

If you have just installed GNU/Linux and would like to know how to install software on your new OS, I would recommend you read the "Compiling and installing software from source" section, as well as the section specifically for your GNU/Linux Distribution. Note that for new users, it is generally easiest/best to install software using the default package tool included with your particular distribution.


Compiling and Installing software from source
Some software is distributed in "Source form". This means you download a file containing all the source code for the application you want to install, unpack it, and compile it on your system. Compiling is the process of turning the source code into an executable binary. The common myth and newbie assumption is that this is very hard todo, or it is only for programmers. Wrong. It is a fairly straight forward process, and you will find that a lot of software you install will need to be built from source.

Typically applications you must compile from source will come as a ".tar.gz", ".tar.bz2", or ".zip" file.

You'll probably want to operate from inside your home directory. If your user is (for example) username, your home directory will be /home/username/. For the rest of this section we will assume you have downloaded your zip file to /home/username/src. If you do not have a src directory, you can create it with the following "mkdir" (make directory) command:


Code:
mkdir /home/username/src/
So, we have our source package in /home/username/src/.

Change to the /home/username/src/ directory with the "cd" (change directory) command like so:

Code:
cd /home/username/src/
Use the "ls" (list directory contents) command, to see the file is present:

Code:
ls

We now need to unzip the zipped file, this is done differently depending on the file extension.

for files ending in .tar.gz, use:
Code:
tar -zxvf 
(replacing with the name of the file).

for files ending in .tar.bz2, use:
Code:
tar -jxvf 
for files ending in .zip, use:
Code:
unzip 
You should now have a new directory, containing all of the source files. To confirm it exists, and to get its name, use the "ls" command again.
Code:
ls
we now need to go into the new directory, so use the cd command:
Code:
cd 



This is where things will differ. Some packages will have an INSTALL or README file which will contain installation instructions. use "ls" to see if the software has an install or readme file. If it does have one, you can use the "more" command to read it, like so:
Code:
more INSTALL
Generally, the final 3 stages are as follows:
- Configure the installation
- Compile the software
- Install the binaries

The pre-installation configuration is done by executing ./configure:
Code:
./configure
This will perform some requirements testing on your system, and create a "Makefile" which will explain to the "make" utility how the software should be compiled. If you receive any error messages during this stage, you may wish to search the forums to see if they have been found and resolved by someone else already, if not, feel free to post a question on the forums - Please include all of the output including any error messages, and some details about your system - what distro you are using, what are you trying to install etc etc


The next stage is to compile the software, this is done using "make". When you run "make" it will read the instructions in the Makefile and build the application binaries.
Code:
make

The final stage is to install these binaries, ie, copy them to a more permanent location. Typically only the "root" user can do this, so you will need to swich to the root user with the "su" command:
Code:
su
Once you are root, install the binaries using the "make" command, followed by "install", like so:
Code:
make install
That is it! Check the user documentation of the software you installed for details of how to run the application.


Installing RPM's using the Redhat Package Manager
Redhat RPM's offer a flexable and easy method to install new software. Software installed from an RPM package differs from compiling from source in a few ways, but the most important one of all is the software is already compiled for you. Essentially all you are doing is extracting the pre-built binaries and copying them to their pre-selected destination. RPM's are files that have a ".rpm" extenstion. The good point about RPM's is installation of new software, and maintaining the software currently installed is much easier than doing so for individual packages compiled from source. The downside to RPM's is that you dont have as much choice about where software is installed on your system, how it is compiled, and how it is configured.

Using the RPM system is fairly straight forward. To install a package, you can use the following command:

Code:
rpm -i 
When using rpm, you must be logged in as the root user. The "-i" flag in the above command means "install".

Un installing a package is just as easy:
Code:
rpm -e 
The "-e" switch used here means "erase" (un install).
Note that is different from used when installing.


For example, if you are installing an application called "mysoftware", you may use a command like "rpm -i mysoftware-1.0.2-i386.rpm" to install "mysoftware", when removing we dont follow the filename for installation, but rather the name of the software itself.

For further uses of RPM, please use "rpm --help" and "man rpm". Also see this page, which has some fairly useful information.


If you need to find & download the RPM file for a piece of software, I recommend using
RPM Find and RPM Pbone Search Note that not all applications are available as RPM's, in these cases you will need to compile the software from source. (see above).


Installing software with Apt-get

APT (Advance Packaging Tool) is a wonderful package management system. It consists of different tools, which names usually begins with "apt-" : apt-get, apt-cache, apt-cdrom, etc. Unlike RPM, which equivalent in a Debian system would probably be DPKG, apt-get handles dependencies resolution and takes care of downloading the software for you (much like YUM in a Red Hat system).

Though apt-get is generally used to install binary packages, it also can build and install source packages (like Gentoo's emerge). One can further more ease the process of installing software by using Synaptic (Graphical Interface), which is considered more featured APT frontend.

aptitude
is a terminal-based apt frontend with a number of useful features, including: a mutt-like syntax for matching packages in a flexible manner, dselect-like persistence of user actions, the ability to retrieve and display the Debian changelog of most packages, and a command-line mode similar to that of apt-get. One should use aptitude to install meta-packages because aptitude keeps log of all packages that are part of meta-package. Its easy to remove/un-install meta-package in one go with aptitude.

One must have root privileges to execute apt-get or aptitude commands. Execute 'su' in Debian and prefix 'sudo' in Ubuntu to gain root privileges.

apt-get depends on Debian packages repositories (where are stored both sources and binary packages) that can be configured in the file /etc/apt/sources.list. A typical Debian stable sources.list would look something like this :
Code:
#Local Mirror 
deb ftp://ftp.us.debian.org/debian/ stable main contrib non-free 
deb-src ftp://ftp.us.debian.org/debian/ stable main contrib non-free 

#Security Updates 
deb ftp://ftp.us.debian.org/debian-security/ stable/updates main contrib non-free 
deb-src ftp://ftp.us.debian.org/debian-security/ stable/updates main contrib non-free
APT includes a tool called apt-setup, which can be summoned from the command line, to help you configure a proper /etc/apt/sources.list file, optimized for your needs and geographic location.

One can also configure APT to follow the testing or the unstable distribution of Debian.

Once the user has a sources.list adapted to his/her needs, the local list of packages needs to be updated :
Code:
apt-get update
Only then can the repositories be browsed with apt-cache.

To search a package from its text description :
Code:
apt-cache search 
Replace with an application name or word. For example,
Code:
apt-cache search irc client
will display a list of several irc clients.

To know more about a package and its description (dependencies, functionnalities, maintainer's identity, etc.) :
Code:
apt-cache show 
In this case you have to replace with the exact package name.


Installating a binary package is done in one single step :
Code:
apt-get install 
Another neat feature of apt-get : it allows to build and install a source package. Minimally, two steps are needed in order to do that. First install the package dependencies :
Code:
apt-get build-dep 
Secondly tell apt-get to build and install the package itself :
Code:
apt-get source -b 
For example, installing the email client "pine" can be done like that :

Code:
apt-get build-dep pine 
apt-get source -b pine
Uninstalling a package is done like this :
Code:
apt-get remove 
Or if you wish to remove the package along with all of its configuration files (essentially doing a clean uninstall):
Code:
apt-get remove --purge 
A word of caution : apt-get handles dependencies in a very strict manner. If you try to uninstall a piece of software that other pieces of software depends on, apt-get will also want to uninstall them (not before warning you about the situation).

Further reading : Debian Reference, Chapter 6 - Debian package management
For the impatient : Debian Quick Reference, Chapter 3 - Debian package management
__________________
nstalling software on Mandrake with urpm
urpm is a nifty was to install software on any 7.x or greater Mandrake system. Some of the advantages of Mandrake's urpm utilities are:

* It automatically solves package dependencies issues by installing or uninstalling dependent packages.
* It installs packages and dependencies directly from the internet.
* It allows globbing of package names
* It will automatically update your system.
* It will install all those "not allowed to distribute" programs that you really want to have (DVD support, MP3 enoders, etc...)

How do I install urpm?
urpm should be installed by default on any modern Mandrake distobution. If it's not, you can install it using the Mandrake Control Center (MCC).
urpm Commands
urpmi

The most commonly used command is urpmi. This command allows you to install packages from your configured sources (see below). urpmi will try to install all package dependencies. It will also take partitial names and give you a list of available packages. For exmaple, if you wanted to install one of the kdemoreartwork styles, but didn't know the exact name, you simple type


Code:
[root@cayanne ~/]#urpmi kdemoreartwork
and it should return a list of packages not already installed on your system. This also means it will install the most up to date package for your system, you don't have to know which version you're looking for. As an exmaple, you may wish to add DVD Play back support to your computer. This can be done by installing any video player, such as Xine or MPlayer, along with the package libdvdcss. Rather then having to type in urpmi libdvdcss-1.2.1-1.i386.rpm, you can simply type in

Code:
[root@cayanne ~/]#urpmi libdvdcss
urpme
The urpme command deletes, or erases, currently installed packages and all packages depandant on that it.

urpmq
The urpmq command searches for, or queries, for packages that you list.

urpmf
The urpmf command does an advanced search for a filename in all known packages. For example if we are trying to compile a program and the configure script is complaining about not finding ncurses.h, we can do a urpmf ncurses.h to find that it is part of the libncurses5-develpackage.

Code:
[root@cayanne ~/]#urpmf ncurses.h
libncurses5-devel:/usr/include/ncurses.h
libncurses5-devel:/usr/include/ncurses/ncurses.h
php-devel:/usr/src/php-devel/extensions/ncurses/php_ncurses.h
urpmi.addmedia
urpmi.addmedia does exactly that, makes an rpm reposatory available for urpm to utalize. Typically, you have your installation cd's available as a default media, these are called main. In addition, you also have three other media - updates,contrib and PLF. Updates is the updates, and contrib is user contributed rpm's and PLF is all those not available for distribution for so-called legel reasons rpm's. The sysntax for urpmi.addmedia is

urpmi.addmedia [media-name] [ftp-address with] ../base/hdlist.cz
Note that the hdlist.cz is required. For example, to add medium 'contrib', we use the following command

Code:
[root@cayanne ~/]#urpmi.addmedia contrib ftp://ftp.sunet.se/pub/Linux/distributions/mandrake/updates/8.2/RPMS with ../base/hdlist.cz
added medium contrib
retrieving description file of "contrib"...
...retrieving done
retrieving source hdlist (or synthesis) of "contrib"...
...retrieving done
examining whole urpmi database
urpmi.removemedia
This command removes specified media. Need I say more?

urpmi.update
The urpmi.update command goes through all of your media sources and updates your installed packages if necessary.

How do I set up urpm?
urpm can be set up using MCC, but I've personally found the instructions at the web-site Easy Urpmi to be a little easier. Either way, you can use the site along with MCC or the console to add media. Simple follow the step-by-step instructions, and enter the command it prints out in the grey box into any terminal window, as root of course. You can even copy and paste the command, there's no need to type it all in.
Installing with fedora / yum
Most of the same commands used with Debian's apt-get are used with yum, such as

yum install
yum remove
yum update

 
Installing slackware packages
Slackware packages are usually .tgz files containing pre-built binaries. To install software in slackware you will need to find and download the .tgz package manually beforehand. If you are looking for a slackware package for a piece of software and have not found it yet, search Linux Packages for it.

Ok, once we have our package, lets install it. To install slackware packages, ensure you are the root user using the command:
Code:
su
Now run the following command to install the package:
Code:
installpkg 
Uninstalling a package is also quite simple:
Code:
removepkg 
Also worth noting about slackware packages, is a utility called pkgtool which will allow you to install, remove and list packages on your system. To use pkgtool, run:
Code:
pkgtool
and follow onscreen prompts.

Anyone who likes the debian apt-get system but is currently using Slackware may be interested to hear about a utility called slapt-get, the Slackware answer to apt-get. Slapt-get is avaible from Here. There is also a nifty Gnome/GTK front end for slapt-get in development, you can preview it at the same url.

Lastly, if you are having trouble locating a slackware package, but have been able to find a equivilent RPM, you can "convert" that RPM to a slackware package which you can use with the installpkg and removepkg commands. To convert your RPM to .tgz, use the command:
Code:        rpm2tgz .rpm  
 
 
 
 
Installing Binary Files and Scripts (.BIN/.SH)

Binary files (.BIN) and shell scripts (.SH) are another popular format for distributing applications, particularly in the commercial, closed-source world. A good example of this are the Quake 3 and Doom 3 games from id Software. Basically all these files are is a list of commands that are run inside a terminal to copy, move, and create files in your file system. You can run these files like so:

For BIN files:
1. Make sure the file is set to "executable" by running this command:
Code:
chmod +x NameOfYourFile.bin
2. Run the file like this:
Code:
./NameOfYourFile.bin
NOTE: If the installer requires access to directories outside of your /home/ directory, you may need to log in as root before you can execute these commands successfully. That can be accomplished with the su command, followed by your root (Administrator) password. Ubuntu users will use sudo and their regular user password instead.

For .SH files:
1. Make sure the file is executable by following Step 1 above.
2. Run the file either with the same command as the previous Step 2, or like this:
Code:
sh NameOfYourFile.sh
________________
Installing .package Files

In recent years some folks have decided that the existing systems for package management (RPM and DEB) are lacking in certain ways and these people have seen fit to create other systems for installing software. One such system is AutoPackage.

The file extension for AutoPackage files is .package, and they are essentially executable shell scripts that build the desired software on your local machine regardless of its package management system. AutoPackage files can resolve dependencies similar to RPM and DEB.

To install an AutoPackage file, download it to your desktop and right-click on the file. Then select "Properties" and choose the Permissions tab. You will see a different screen depending on your distribution of Linux, but you should see something that says "Executable" or "Execute." Check that permission.

Close the dialog and double-click on the .package file. A dialog may pop up asking you if you want to Run or Display the file. Click Run. The install will begin and any further instructions will display in a terminal window.

Optionally, you can perform this procedure from a terminal window. Simply launch the file using a script interpreter such as SH:

Code:
sh nameOfYourPackage.package

No comments:

Post a Comment