Installing software in Linux

480
By Jenn Vesperman

Installing software can be confusing. Make this, run that, download this, display that. At first glance, it doesn’t make sense. In reality, there are only a few techniques. These techniques are used in different ways, or called in a different order, but once you know the main techniques you can recognize them and make sense of software installation.

Packages

Most Linux distributions use package systems, which contain programs ready for installation and a record of what else those programs rely on.

When a package is installed, the installer checks whether the other files the program will need are present. Each installer handles missing files differently.

There are two major types of packages for Linux systems. .rpm, used by Red Hat Linux and distributions based on Red Hat (such as SuSE and Mandrake); and .deb, used by Debian Linux and distributions based on Debian.

Package managers can also be used to remove or upgrade software.

.rpm and rpm: To install a .rpm on a Linux system that uses rpms, first download the file then use the rpm package manager. The graphical versions are gnorpm for Gnome systems, and KPackage for KDE. If you use neither, the command line version is rpm --install (package file) .

On the command line, run rpm --install --test (package file) to determine which packages are needed by the package you’re trying to install, and any other conflicts that the new software may cause. If this shows packages that aren’t installed on your system, rpm may need to install those as well.

You can also find out which packages are required with rpm --query --requires -p (package file).

apt, deb and dpkg

deb packages are designed for Debian Linux. The apt system is the simplest way to retrieve and install packages for Debian Linux.

apt: apt is a system for installing packages. It can be used for both types of package, and is primarily used on Debian systems.

To use apt, you need to set up an apt source. On Debian systems, the debian-config program sets up the sources during the installation process. Apt sources are locations where packages and package information can be downloaded. Once you have an apt source set up, the command apt-get install (package name) will install the package for you, and also install anything the package requires.

If you do not know the package name, the command apt-cache search (keywords) will search package names, file names and package descriptions for the keywords; and present a list of matching packages.

$ apt-cache search cervisia
cervisia - KDE based CVS frontend

The command apt-get update will automatically update the source and package lists, and should be used if you want the latest version of a package.

dpkg:
The Debian package manager is another way to install .deb packages. dselect is a graphic front end to dpkg, and can be called by running the command dselect from the command line.

dpkg can be run directly from the command line, if desired.

alien:
alien will convert one sort of package to the other. It works on rpm (Red Hat), deb (Debian), slp (Stampede), pkg (Solaris) and tgz (archived and compressed) files.

The alien manual explicitly states not to use it for system-critical programs, only for applications.

Unpackaged software

If a program is not packaged, it will usually come as a compressed archive. The archive may contain source code, precompiled binaries, and/or scripts.

All of these will need to be installed before they can be run. Source code will need to be compiled. Precompiled binaries and scripts will just need to be installed into the correct locations.

Scripts need an interpreter to be installed on the system they will run on — most Linux systems will already have interpreters for the most common scripting languages. Some scripts can be interpreted by a Linux shell.

Preparing the software: Software that isn’t in a package is usually in some sort of archive. The most common archiving system is tar. Archives are then usually compressed, with one of the zip family of compression tools.

Download the archive file, and put it in its own directory in /tmp. Then cd to that directory, and run the appropriate un-archive and decompress commands. Run the last extension first, so if a file is called filename.tar.gz, you should ungzip it before you untar it.

Note: While the zip family of tools bear the same name as the Windows zip compression tools, they are only loosely related.

Tarred archives have the file extension .tar.
To untar a file, run the command:

tar -xvf (file name)

Zipped compressions have the file extension .zip.
To unzip a file, run the command:


unzip (file name)

Gzipped compressions have the file extension .gz, .Z, .z, .taz and .tgz.
To ungzip a file, run the command:


gunzip (file name)

Bzipped compressions have the file extensions .bz, .bz2, .tbz or .tbz2.
To unbzip a file, run the command:


bunzip2 (file name)

There may be other archive formats, or other things to be done before compiling or installing the software. If there is anything unusual to be done, there should be instructions on the site where you found the software, or with the downloaded file.

Compiling: Most developers provide README or INSTALL files in the program archive. These are text files that include instructions on compiling and installing the program.

Linux provides a developer’s utility called make. This utility allows the developer to provide a script called a Makefile, which, when run through make, will compile the program automatically. The Makefile can also include installation instructions.

In most cases, change to the directory containing the source code, then run the command make, followed by the command make install. There might also a configure script that needs to be run with ./configure before the make command.

Some software, usually CVS snapshots of open source code, comes without a configure script but with an autogen.sh file. If the documentation is unavailable or unclear, leave this for a more experienced user.

Binaries and scripts: As with compiled software, most developers provide files called README and INSTALL, in the program archive. These files should provide installation instructions. Many programs will have an installation script, that installs the software automatically.

The most common form of installation script uses the program make. These are usually called with the command make install.

Script interpreters: Programs that are distributed as source code, but do not require compilation, are dependent on special programs called interpreters. If the interpreter is not available on your system, the script will not run.

To fix this, install the appropriate interpreter. The most common interpreters are available as both .rpm and .deb packages.

Final Words

These are just general guidelines. If the instructions with the software tell you to do something different, trust those instructions rather than this article. If you have a package manager that you like that works for your distribution, use that.

If the software fails to install on your system and neither the instructions with the software nor this article helped, file a bug report with the maintainer of the software. Include everything they ask for, and be sure to include the distribution and version of your operating system.

Further reading

  • man and info pages for alien, apt, bzip2, dpkg, dselect, gnorpm, gzip, KPackage, rpm, tar and zip.
  • The instructions with the software you want to install.
  • The bug reporting instructions with the software you want to install.