Package management on Linux

Package management on Linux

By | January 1st, 2014
Comments Off on Package management on Linux

Learn the easy way to package your software into .deb and .rpm like a



Traditionally, Linux being an open source platform, users have been restricted to developers and software enthusiasts who prefer to compile packages from source. But as more and more normal users continue to adopt this platform as an alternative to Windows, package managers have emerged as a new breed which have become all the more important to differentiate how each platform manages and keeps track of
where individual files and packages are installed on a Linux system.


Package management in Linux is usually present as an all in one solution to managing and updating everything related to your applications, and unlike Windows, Linux package repositories contain almost every software package that you might ever need. This not only provides a one stop solution for updating all the installed software, but also tracks and manages dependencies that each package might have. Dependency resolution is one beast that can be very difficult to tackle if done manually. Modern package managers however, make this a breeze. Today, Linux software repositories resemble more like an app store for mobile platforms, where you just give the command to install something and it gets done without you having to worry about any installation wizard. All thanks to the package manager under Linux, which knows exactly which files and configurations belong to a particular package.

It is not very difficult to get up and running with creating packages on Linux. Among others, there are two widely popular package management systems that we will be discussing i.e. Debian based and Red Hat/Fedora based.

Debian based packaging

Debian packages are used in Debian based Linux distros, where a binary software package is available in the form of a .deb file. This file contains within itself all the metadata related to the package.

The dpkg utility is the main package management program which performs all the primary functions of installing removing and providing information about the .deb files. Mainly one can interact with deb packages using this command as follows: –

• Installing a deb package: dpkg -i debfilename
• Removing an installed package: dpkg -r packagename
• List of installed packages: dpkg -l
• Query whether a package is installed or not: dpkg -l ‘packagename’
• Determine the package name to which a given file belongs to: dpkg -S /path/to/file
• Show metadata about a package: dpkg -s packagename

Apt or Advanced Packaging Tool is designed to work on top of the dpkg tool and further simplifies the task of package management by performing higher level functions like sourcing of deb files from their repositories and managing the relations between multiple packages. Apt is more like a collection of tools where the apt-get utility being the most important one, works with package names, unlike dpkg which works with deb file names. When a package is needed to be installed, it automatically resolves all the required dependencies if they are available in its list of online package repositories.

One can use the following commands to interact with apt: –
• Install and update software on the system: apt-get install packagename
• Remove software: apt-get remove packagename
• Update package list: apt-get update
• Upgrade the system: apt-get upgrade
• Search for a package: apt-cache search packagename

Packaging software for the Debian based systems

One of the most important things that you need to learn is to package and publish the code to make it available for the end users. Lets try and do this in a step by step manner as part of our simple tutorial.

Before you begin with creating packages, make sure that the following packages are installed on your system to enable you to use the utilities related to creating a deb package: –

• build-essential
• devscripts
• debhelper
• lintian

In order to understand the concept of creating packages, we need to learn that creating a package is mainly a three step process: –

• Procuring the source tarball : The source tarball is the compressed tar file of the source code of the application to be packaged, eg. packagename.tar.gz

• Creating the Source package : This step involves adding Debian specific packaging files and any modifications that you want to make to the package. This is done under a special directory named ‘debian’.

• Building the package: Once the source package is ready, it can be built to create a binary package which can then be finally installed on the system. In the first step, the source tarball needs to be renamed speciafically according to the accepted standards, mainly the fact that it needs to in lowercase characters and in the format like: – mv packagename-1.0.0.tar,gz packagename_1.0.0.orig. Tar.gz We can now unpack the source tarball and create the debian subdirectory under the source tree. Inside this directory following files are necessary to be provided: –

• changelog : This file summrizes the list of changes in this particular version of the package as compared to the previous version or mention that it is an initial release in case it is being packaged for the first time. This file can be easily created using the dch command as follows: –

dch –create -v 1.0.0 –package packagename


This will create a changelog file with a format as follows: –
vlc (2.0.8) UNRELEASED; urgency=low
* Initial release. (Closes: #XXXXXX)
— Ankit Mathur <ankit@ankit-laptop> Sun, 15 Dec 2013 19:10:31 +0530

• compat : This file specifies the compatibility level of the application for debhelper, which contains a single digit number like 9 or 8 as its contents.

• control : This file provides information about the source and binary package, mainly details about the maintainer, priority, section, dependencies, description etc. A sample control file looks as follows: –
Source: helloworld
Section: unknown
Priority: extra
Maintainer: Ankit Mathur <ankit@unknown>
Build-Depends: debhelper (>= 8.0.0)
Standards-Version: 3.9.4
Homepage: <insert the upstream URL, if relevant>

#Vcs-Git: git://

#Vcs-Browser: helloworld.git;a=summary

Package: helloworld
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: <insert up to 60 chars description>
<insert long description, indented with spaces>

• copyright : This file keeps track of legal and copyright information.
• rules : This file acts as the makefile and consists of rules each of which specifies a target and how it is executed. This target specifies the various build targets which can be overriden when executed in the debhelper sequence.The most basic file looks like this: –

Go to Page: 1 2

Ankit Mathur
I have a crush on Java, open source and linux. I also love flirting with almost all other stuff related to mobile and web technologi​es. Feel free poke fun at my articles and I tweet: