Home Classroom Linux Basics Linux Basics Part 7

Linux Basics Part 7

1055

Yum and APT

In the last issue we discussed some basic concepts behind package management in Linux. It is probably good to remind again that in moder Linux distributions installing/uninstalling software is handled via a package management tool. It might not be a very familiar concept to people from different backgrounds such as Windows and MacOS. However Linux users must be quite familiar with how managing packages are done.

The main plus point is you can get all the software you need using one method and having the ease of updating the system, and also keep receiving updates automatically. Once you wrap your head around the basics you will noticed that Linux is one of the easiest environments to install, manage and remove software. Package management itself is one of the features that sets Linux apart from the rest od the mainstream operating systems.

If you have not heard already, there are several package management system approaches in the Linux world. Here are some of the commonly found ones.

 

  • RPM/Yum – Used by Fedora, Red Hat Enterprise Linux, CentOS, openSUSE, SuSE Linux Enterprise Server, Mandriva, etc.
  • DPKG/APT – Used by Debian, Ubuntu, Mint, etc.
  • Portage – Used by Gentoo

There are many other tools available in the form of TGZ format files in Slackware distribution and so on. However RPM and DPKG based systems are notable very popular. Each of these systems may use a different set of tools for operations.

 

Relationship between packages, formats, tools and systems

We discussed what a package management system is, in the last issue. So you should have a fair idea about what to expect. In an extension to that we already discussed what is the relationship between a package management system and its tools. In short package management tools are the software tools we use to execute operations in a package management system. A package format is the anatomy or the composition of a package archive, while a package itself is a single archive of that particular format.

In example RPM based package management systems uses software packages of the RPM format and use tools such as “yum” command to execute operations such as add remove software.

Today we are going to look into the two most popular package management tools: Yum and APT.

 

RPM and Yum

RPM stands for RPM Package Manager (used to be Red Hat Package Manager). It was started by Red Hat but later became the package management infrastructure of choice for many Linux distributions including Fedora, RHEL, CentOS, openSUSE, SLES, Mantriva and more. Another notable fact about RPM is that it is the package format used in the Linux Standard Base, a standard for Linux distributions maintained by the Linux Foundation. If you do not know about the Linux Foundation, it is the primary non-profit consortium chartered to foster the growth of Linux which is also the employer of Linus Torvalds (creator and maintainer of Linux).

The native package format used in RPM is also named RPM packages usually with the extension “.rpm”. For example a released RPM package for the software called “checkinstall” could be “checkinstall-1.6.1-1.i386.rpm”. In our simple example we can notice that the software package in question is named “checkinstall” and is in the version 1.6.1-1 for the i386 (x86) hardware architecture.

RPM package format was developed earlier to be used in discreet package releases. Which means each and every new release would be a completely new full package. However recently the concept of package-deltas in the form of delta-rpms were added into this systems. This enables the RPM system to fetch only the changed portions of the software when a new version is released.

The command line utility to execute operations within the RPM system is named “rpm”. Let us now see a few RPM related commands.

To install a downloaded new package (located in the working directory) named “somepackage” with the version number 1.0.0 and hardware architecture neutral:
# rpm -ivh somepackage-1.0.0-1.noarch.rpm

To upgrade the “somepackage” from an older verion to the new version:
# rpm -Uvh somepackage-1.1.0-1.noarch.rpm

To freshen the package “somepackage”. Works only if “somepackage” is already installed
# rpm -F somepackage-1.1.2-1.noarch.rpm

To uninstall the package “somepackage”:
# rpm -e somepackage

To query which packages with a name starting with “some” are installed
# rpm -qa some*

To query the files installed by the package “somepackage”
# rpm -q somepackage --filesbypkg

To query which package incuded the file /etc/nanorc
# rpm -q -f /etc/nanorc

The RPM system was designed to handle only one version of a given software in a given system. This behavior complies with most of other package management systems available for Linux.

Even though RPM identifies missing dependencies for a package, RPM itself does not provide an easy means of solving dependency related issues. This and several other new features combined gave different vendors the idea to build high-level tools based upon RPM. For example tools like “yum” and “urpmi” came into being.

Yum started it’s life as YUM, the Yellow Dog Updater Modified as a part of the Yellow Dog Linux distribution. It was since been adopted by Red Hat as the preferred high level tool for package management providing additional features on top of RPM. For example it provides an easy means of handling dependencies by incorporating the concept of package repositories.

 

New Concept: Package Repository

A package repository is a location where a collection of software packages are stored for easy retrieval. For example most Linux package management systems use repositories to provide much needed software compilations where you can select and install. For example a 3rd party repository called RPMFusion (located at rpmfusion.org) is very popular among Fedora Linux users. Meanwhile the Fefora project hosts their official repositories too.

These package repositories can be added or removed from a system with ease. Fedora, RHEL and similar stores Yum package repositories related information inside the directory: “/etc/yum.repos.d/” directory while Debian/Ubuntu systems store APT repository information in “/etc/apt/sources.list” file.

So let us try a few Yum commands.

To search if there is a package with the pattern “vpn” in its name or the description
# yum search vpn

To list the details of the package “openvpn”
# yum list openvpn

To install the package “openvpn”
# yum install openvpn

To update the package “openvpn” into the latest version available
# yum update openvpn

To remove (uninstall) the package “openvpn”
# yum remove openvpn

To search for the names of package groups starting with “gn”
# yum grouplist gn*

To install the package group “GNOME Software Development”
# yum groupinstall "GNOME Software Development"

To downgrade the version of the package “leafpad” from the current version to the previous highest version
# yum downgrade leafpad

To see the summery of the past Yum transactions
# yum history

Further, Yum has this advanced mode called the yum shell. Yum shell is an interactive environment where you can run Yum based commands in succession. Once you have completed your commands you have to option to commit the changes you made. Yum will then take your operation and execute all in one single transaction. This feature alone can make a big difference in tricky situations.

Yum Shell can be invoked by running
# yum shell

As you can see clearly Yum/RPM provides a powerful package management infrastructure. It is also worthy of mentioning that RPM is the preferred format in the upcoming MeeGo distribution for Linux based hardware device (Eg: mobile phones, tablet PCs, media players, e book readers, etc.) sponsored by Intel and Nokia.

 

DPKG and APT

While RPM was available for Red Hat Linux in the 90s, Debian project had their own package management going. Their package format was called a Deb package which usually had the extension “.deb”. The command used for the operations was called “dpkg”. Here’s a few “dpkg” commands.

To install a downloaded new package (located in the working directory) named “somepackage” with the version number 1.0.0 and hardware architecture of i386:
# dpkg -i somepackage-1.0.0.i386.deb

To uninstall the package “somepackage”:
# dpkg -r somepackage

To query which packages with a name starting with “some” are installed
# dpkg-query -l some*

To query the files installed by the package “somepackage”
# dpkg -L somepackage

To query which package incuded the file /etc/nanorc
# dpkg -S /etc/nanorc

Even though the development of decent high end tools for RPM was fairly new, Debian had the upper hand there. They had APT, which stands for Advanced Package Tool for quite some time before Yum came into being. Naturally APT was better geared than “dpkg” to handle dependencies.

So let us now try a few APT based commands:

To search if there is a package with the pattern “vpn” in its name or the description
# apt-cache search vpn

To list the details of the package “openvpn”
# apt-cache search openvpn

To install the package “openvpn”
# apt-get install openvpn

To remove (uninstall) the package “openvpn”
# apt-get remove openvpn

As you can see APT also provides a feature set complete with advanced options. The choice of package management tools between APT and Yum are thus, largely a personal choice. It is however very incorrect to compare “apt-get” to “rpm” or, “yum” to “dpkg”. The low-level commands for each platform are “rpm” and “dpkg” while the high-level tools are “yum” and “apt-*” respectively.

Additionally there is a tool called “apt-rpm” which enables the use of APT system on RPM based distributions (Eg: Fedora, RHEL/CentOS). New generation tools like Smart Package Manager and PackageKit has the ability to use more than one package management toolset in a single system.

 

Graphical Frontends

Other than the command line tools, both of the above systems sport several GUI tools as frontends to their respective package management systems. Let us now take a brief look at two of them.

Recent versions of the Fedora distribution ship with a GUI application named “gpk-application” (mainly for GNOME Desktop Environment). It is a better replacement to the GUI tools previously available. The “gpk-application” also relies on the Yum/RPM and PackageKit integration in Fedora. It has the ability to search for packages, mark packages for install/uninstall operations, search and install package groups among other features. This tool is likely to appear in future versions of RHEL and CentOS too.


Image 1: gpk-application
On Debian/Ubuntu systems, again (mainly for GNOME Desktop Environment) there is the Synaptic Package Manager working as a frontend for DPKG/APT. It also has the ability to search for packages, mark packages for install/uninstall operations, among other things. One nice feature is the ability to generate a list of packages for future use or a script for separate downloading. It is also available under Ubuntu and Mint.


Image 2: Synaptic Package Manager

Comments

comments

Gaveen is a Linux System Administrator with several years of industry experience and is a strong FOSS promoter. He is pending graduation from University of Wolverhampton and also holds a certification from Red Hat. He also conducts Linux trainings with Red Hat training partners. Being highly enthusiastic about computing, he supports a keen interest in Ruby programming too. When not distracted by his wide range of interests including reading, music, cricket, etc.,he regularly blogs at Gaveen's Blog

NO COMMENTS

Leave a Reply