Buscar

Linux Package Manager: The Debian Style

The author of this post is: Ahmed Bilal Jan (linkedin.com)

If you have just started using Linux you probably will be saying why people call this operating system an unfriendly?

It’s has almost everything that an operating system has to be classified as user friendly.

Believe me those were opinions of people who used Linux back in early 2000.

I remember when I started using Linux back in 2007 I have to issue mount command in shell to mount my USB stick for using it on Redhat Linux.

As a student we were mostly reluctant in using Linux since we were told that you can’t play your media files in Linux. Excuse me!!! No media files? Our answer was no media files means no computer for us.

Though there were many other such limitations in those days that classify Linux as an operating system only for experts only.

We were happy to use Windows in those days since we can easily play our media files in it.

One of the most challenging thing at that time was installing a software on your Linux distribution.

You download a tar file from Internet and go through its readme file and then when you start installing it you were prompted that the software you trying to install has dependency on some X library when you try to install X library you were told that X has dependency on Y please install first Y and the story continuous on.

Thanks to Linux package manager users nowadays don't have to bear all that.

In this article I am going to explain how package manager works in a Debian based distribution.

Although name of package manger differs in rpm based distribution but the principle on which package manager works remain the same.

In Debian based distribution the installable binaries of software came in the form of files with .deb extension.
 
To install these .deb files, there is a command line tool available called dpkg, short for Debian package manager.

The dpkg only install the .deb file which is passed to it as an argument. It doesn't take the responsibility of installing the dependency files and also no configuration setting is being done by dpkg.

You can say dpkg is manual method of installing a file. For example to install a package we issue following command in terminal:

    $ sudo dpkg -i packagename.deb
 
To view all installed packages:

    $ sudo dpkg -l

To remove a package let say name tcl, we use:

    $ sudo dpkg -r tcl

To find out which package a file belongs. Let say we need to find package of networkctl file:

    $ sudo dpkg -S /bin/networkctl

There is no guarantee that software which you are trying to install may got installed in first go. It may prompt you with message that software you trying to install is dependent on some library which is missing please install it first.

To overcome the limitations of dpkg, software developers invented the apt-get utility for Debian based distribution.

It is referred as front end of dpkg in a sense that real package manager is still dpkg.

A part from installing new software apt-get do the dependency work for you, as its automatically install all dependencies and also do configuration settings for you.

The apt-get can also be used to un-install a package and update a package. Some example of apt-get utility are:

To install a package:

    $apt-get install [package name]

To remove a package:

    $apt-get remove [package name]

There are three apt-get commands: update, upgrade and dist-upgrade

    $ sudo apt-get update
    $ sudo apt-get upgrade
    $ sudo apt-get dist-upgrade

The update command only update the list of available packages and their versions, but it does not install or upgrade any packages.

While the upgrade command upgrade the software installed on your system.

It is recommended that you should first run “apt-get update” so that package manager knows the latest version of software available.

The third one “apt-get dist-upgrade” do the same thing of updating softwares installed on your distribution. In addition “apt-get dist-upgrade” also smartly handles the  dependencies.

It also intelligently handles changing dependencies with new versions of packages.

There is GUI version of apt-get as well. To install GUI version of apt-get use following command:

    $ sudo apt-get install synaptic

You can access synaptic by tying synaptic in terminal. Synaptic can do all tasks which can be done by command line apt-get like installing, un-installing and updating package.

One important thing to mention here is repositories.

You can see repositories in file /etc/apt/sources/list.

Whether you use command line utility like apt-get or its GUI counterpart they both make use of repository in /etc/apt/sources.list.

If you open this file you will see lines starting with deb followed by web links.

A repository is collection of software for your distribution on server.

Your package manager apt-get or synaptic goes to these servers and grab the software you want to install along with their dependencies files. A typical line in /etc/apt/sources.list looks like this:


deb http://pk.archive.ubuntu.com/ubuntu/ xenial main restricted

You may enable or disable lines in repository. Lines starting with # are considered disabled.

Linux package manager can safely be classified as one of the factor which makes Linux an operating system for home use. Without this utility it will be very hard for Linux to be classified as an OS for everyone.

2 comentarios: