On with the real stuff now. Don’t forget the relationship between the various tools: synaptic, aptitude and kpackage depend on apt which in turn relies on dpkg.
APT and aptitude:
APT is the Advanced Package Tool and provides the apt-get program. Unlike dpkg, apt-get does not understand .deb files, it works with the package’s proper name. It downloads the required package + its dependencies from a preconfigured remote location and then calls dpkg to install the individual .deb files. See how everything fits?
In this section we shall discuss package management using the aptitude program instead of apt-get simply because aptitude is the recommended way of managing packages from the command line nowadays. In fact, it hardly makes a difference from the user’s point of view since most of the options provided by aptitude are similar to those of apt-get.
I’d like to point out that aptitude also provides an ncurses-based interface for selecting and installing packages interactively. You can check this out by issuing the aptitude command (without any options).
It’s better to stick with the more advanced synaptic or kpackage programs. When you are getting a graphical interface, why bother with a terminal based one? More on that later.
We can tell APT where to look for packages by editing a special file named sources.list
APT relies on the concept of repositories in order to find software and resolve dependencies. For apt, a repository is a directory containing packages along with an index file.
For extra packages, any number of additional repositories can be added to APT’s sources.list configuration file and then be queried by APT. In addition to network repositories, compact discs and other storage media can be used as well.
sources.list and netselect
First off, we need to tell APT where to look for when installing/upgrading packages. The source repositories are specified in the file /etc/apt/sources.list. Open it up and take a peek:
sudo nano -w /etc/apt/sources.list
Let’s start by adding a fast mirror to this file. We’ll be using the netselect-apt command for this. The netselect-apt program is used to find the fastest among the currently available Debian mirrors. Issue the following commands:
The sources.list file should now be updated. But in order for the changes to take effect, we need to tell APT that the sources file has been modified. We do this as follows:
Remember to issue this command regularly to keep your package lists updated. It’s especially important when you make changes to the sources file.
NOTE: Adding a CDROM repository source:
Using aptitude for package management:
aptitude offers a myriad of options. Some of them are:
- install – Install/upgrade packages
- remove – Remove packages
- purge – Remove packages and their configuration files
- update – Download lists of new/upgradable packages
- upgrade – Perform a safe upgrade
- dist-upgrade – Perform an upgrade, possibly installing and removing packages
- search – Search for a package by name and/or expression
- show – Display detailed information about a package
For eg, to install a new package named “xyz”, issue:
sudo aptitude install xyz
To remove “xyz” along with all its configuration files:
sudo aptitude purge xyz
The upgrade and dist-upgrade options upgrade all installed package in the system to their most recent versions. Thus,
sudo aptitude dist-upgrade
upgrades the entire distribution. And you won’t even require a restart!
Manipulating individual packages – dpkg
Normally, users like me and you never need to deal with individual .deb package files. They are managed as a whole by APT, as mentioned above. But there are cases when this may be necessary. In such cases, we use the dpkg tool directly to manipulate individual packages.
Install a deb package named xyz.deb
dpkg -i xyz.deb
To remove an installed package, run:
dpkg -r xyz
To remove “xyz” along with all its configuration files. (-r or –remove does not delete the configuration files.)
dpkg -P xyz
List all packages installed:
You can combine this with grep to check whether a set of packages is installed or not:
dpkg -l | grep xyz*
To check if an individual package is installed, use the -s flag:
dpkg -s xyz
To see the contents of a Deb package, issue:
dpkg -c xyz.deb
Information about a package:
dpkg -I xyz.deb
To get a list of all the files installed by a package:
dpkg -L xyz
The pretty frontends – Synaptic, kpackage and Adept
Well the fact remains that an average user would use one of the above frontends for nearly all software management tasks. But it’s always helpful to know the tools they are built on. Especially when things don’t work as expected.
The interfaces provided by these tools are pretty intuitive and I feel any average user should be able to find his/her way through it, especially after going through this article. I personally use adept, being a KDE fan 🙂
Onto a bit more advanced stuff now..
Each time you install an application using apt, the package is actually cached in a location on your hard disk. It is usually stored in the location /var/cache/apt/archives/. The apt tool suite also includes the apt-cache tool to query these local package lists.
To find packages whose description contain word:
apt-cache search word
To print the detailed information of a package:
apt-cache show package
To print the packages a given package depends on:
apt-cache depends package
To print detailed information of the versions available for a package and the packages that reverse-depends on it:
apt-cache showpkg package
Display statistics about the packages available in the repositories
You can clear the cache and release hard disk space by using the following command:
Delete useless or partially complete packages.
Well that’s all for now. I’ll add more advanced stuff such as compiling from source and mixed systems when I get time. But for now, I hope this article helped all those fresh Debian converts out there.. Enjoy!