Debian Package Management

This is essentially a Debian version of Fedora Package Management, an entry I wrote recently about some of the details of Fedora's package system. It's not going to be an in-depth discussion of the Debian Package Management system.

A function I've been using for many years to find if a particular package is installed on my system:

dpkgg ()
{
    dpkg -l | grep --color -i "$@"
}

To use it, just type the name followed by a partial package name:

$ dpkgg bash
ii  bash                  4.3-11+deb8u1      i386         GNU Bourne Again SHell
ii  bash-completion       1:2.1-4            all          programmable completion for the bash shell

The information we get out is a little different than what we saw for Fedora.

Another function I use shows how big each package is, and sorts them by size:

dpkgs ()
{
    dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -n
}

The tail-end of the output on a mostly default Debian Jessie system looks like this:

...
23829 git
25557 vim-runtime
27391 libicu52
28265 pidgin-data
29982 g++-4.9
30259 libwebkitgtk-3.0-0
32585 libllvm3.5
33224 freepats
40558 gnome-user-guide
43319 gimp-data
45834 evolution-common
76510 inkscape
105827 firefox-esr
116865 linux-image-3.16.0-4-586

Gimp, a kernel, and Firefox are all shared in common with the largest packages listed for a Fedora system.

Asking the system what provides an existing package is fairly simple (once you know the appropriate obscure switch):

$ dpkg -S $(which cal)
bsdmainutils: /usr/bin/cal

As it turns out, if I'd been using Debian instead of Fedora, I would never have known that ncal isn't common on Linux:

$ which ncal
/usr/bin/ncal
$ dpkg -S /usr/bin/ncal
bsdmainutils: /usr/bin/ncal

If you don't know what I'm talking about, don't worry about it - or go read the Fedora entry mentioned earlier.

Finally, finding out what package provides a binary that's not installed requires another step that wasn't necessary on Fedora: we need to install a package to do this. $ apt-get install apt-file. And you're still not quite ready, you need to tell apt-file to load itself up with current package data: $ apt-file update (you need to continue to do this before you use it, as it won't keep itself up-to-date). Then we can search for a binary:

$ tcsh
bash: tcsh: command not found
$ apt-file search bin/tcsh
tcsh: /bin/tcsh
tcsh: /usr/bin/tcsh