One of the most important feature while choosing linux distribution is it’s packaging system. Packages and Linux distribution keeps releasing frequently and to keep up with this blizzard of software we need a good tools for package management.

Package Management

Package Management is a way of installing and maintaining software on the system. In early days, one had to compile source code to install software. Although, nothing wrong with compiling sources, but this days we can install packages from their linux distributor.

Packaging System

Different distribution of linux use different packaging system and package intended for one distribution is not compatible with another distribution. Broadly, distribution fall into one of the two camps of packaging.

  • Debian .deb
  • Red Hat .rpm

How a package system Works

Unlike distribution found in proprietary software industry usually entails buying a pieces of installation media such as “install disk” or visiting vendor’s website and downloading the product and installing, mostly linux application will be provided by the distribution vendor in the form of package files and rest will be available in source code form that can be installed manually.

Package Files

In linux, package file is the basic unit of software. A packages file is a compressed collection of files that comprise the software packages. Additionally, it includes metadata about the packages. These package are created by the developer know as package maintainer. The package maintainer gets the software in source code form from the upstream provider (the author of the program), compiles it, and creates the package metadata and any necessary installation scripts. Often, the package maintainer will apply modifications to the original source code to improve the program’s integration with the other parts of the Linux distribution.

Repositories

Those packages are made available to the user of a distribution in central repository. Such repositories includes many thousand of packages, each specially built and maintained for the distribution.

Dependencies

Programs are seldom “stand alone”; rather, they rely on the presence of other software components to get their work done. Common activities, such as input/output, for example, are handled by routines shared by many programs. These routines are stored in shared libraries, which provide essential services to more than one program. If a package requires a shared resource such as a shared library, it is said to have a dependency. Modern package management systems all provide some method of dependency resolution to ensure that when a package is installed, all of its dependencies are installed, too.

High- and Low-Level Package Tools

Package management systems usually consist of two types of tools. • Low-level tools that handle tasks such as installing and removing package files • High-level tools that perform metadata searching and dependency resolution

Common Package Management Tasks

Finding a Package in a Repository

Here are the package search command for two main distribution.

Style Command
Debian apt-get update
apt-cache search search_string
Red hat yum search search_string
Installing a Package from a Repository

High-level tools permit a package to be downloaded from a repository and installed with full dependency resolution

Style Command
Debian apt-get update
apt-get install package_name
Red hat yum install package_name
Installing a Package from a Package File

If a package file has been downloaded from a source other than a repository, it can be installed directly (though without dependency resolution) using a low-level tool.

Style Command
Debian dpkg -i package_file
Red hat rpm -i package_file

Because this technique uses the low-level rpm program to perform the installation, no

dependency resolution is performed. If rpm discovers a missing dependency, rpm will exit with an error. Also it is similar for dpkg.

Removing a Package

Packages can be uninstalled using either the high-level or low-level tools.

Style Command
Debian apt-get remove package_name
Red hat yum erase package_name
Updating Packages from a Repository

The most common package management task is keeping the system up-todate with the latest versions of packages. The high-level tools can perform this vital task in a single step

Style Command
Debian apt-get update; apt-get upgrade
Red hat yum update
Upgrading a Package from a Package File
Style Command
Debian dpkg -i package_file
Red hat rpm -U package_file

dpkg does not have a specific option for upgrading a package versus installing one as

rpm does.

Listing Installed Packages
Style Command
Debian dpkg -l
Red hat rpm -rq
Determining Whether a Package Is Installed
Style Command
Debian dpkg -s package_name
Red hat rpm -q package_name
Displaying Information About an Installed Package
Style Command
Debian apt-cache show package_name
Red hat yum info package_name
Finding Which Package Installed a File

To determine what package is responsible for the installation of a particular file.

Style Command
Debian dpkg -S file_name
Red hat rpm -qf file_name