Package tools


This command is meant to query the package database. Some examples:

See if some packages, with the string mysql in the name, are installed or not:

  $ dpkg-query -l '*mysql*'


The dpkg command is at its core meant to install and remove packages.

Summary of dpkg options:

-i deb fileInstall .deb package
-r packageRemove installed package
-P packagePurge installed package including configuration files
-s packageDisplay summary on package name
-L packageList files of package
-S patternSearch in package names and filenames for pattern
-l packageList install status of package, can use wildcards. Use grep "ii" to see only installed ones.

To list all installed packages:

  $ dpkg --get-selections

To find which package owns a file:

  $ dpkg-query -S /usr/lib/

The following will do the same, but fail if the package isn't installed:

  $ dpkg -S /usr/lib/

Some columns look squashed. Try something like:

  COLUMNS=150 dpkg -l packagename | less

To search for a keyword in name and description of all available packages:

  $ apt-cache search ''keyword''

To search for a keyword in names of all available packages:

  $ apt-cache search --names-only ''keyword''

Of you get too much results, remember it's a regex you're searching. To search for all packages that start with 'apache' in the name:

  $ apt-cache search --names-only '^apache'

Once found, you often want more info:

  $ apt-cache show packagename

Search for a package which provides a certain file:

  $ apt-file search mysql.h

Or use the web frontend at

If you don't have apt-file installed, do:

  $ sudo apt-get install apt-file
  $ sudo apt-file update

Search for installed package name which owns a certain file:

  $ dpkg --search "/usr/games/fortune"

Nice trick: show the 10 largest packages on your system:

  $ dpkg-query -Wf '${Installed-Size} ${Package}\n' | sort -n -r | head

To see which packages depend on a specific package:

  $ apt-cache showpkg libevent1

Font size issues

A default Debian Testing installation can have both Gnome and KDE installed. However, when running GTK applications (like Mozilla and Eclipse), the font sizes are not the same size. Adjusting this through gnome-control-center is possible but awkward, since the DPI settings of both desktops are different.

It's easiest to set them to the same DPI. To find the current DPI, start Konsole or Gnome Terminal and type

  xdpyinfo | grep "dots"

Gnome its DPI setting is adjustable through Gnome Control Center, Font. Then press the Details... button. For KDE, you'll have to edit the file /etc/kde3/kdm/Xservers and add to the uncommented line -dpi x where x is the same value as was set through the Gnome Control Center.

Logout and press CTRL+ALT+Backspace. This restarts the Xserver. Now use both KDE and Gnome Control Center to set all apps to the same font size.

Differences in startup

Debian uses the runlevels in a different manner than RedHat and SuSe do. In Debian, runlevel 1 is single-user and runlevel 2 (the default) goes multi-user including network and X.

Note also that maintaining the symlinks in the SysV init-style is done through the 'update-rc.d' utility rather than 'chkconfig'.

Unicode in Debian

If you have KDE and you want your terminals to be aware of unicode, create a directory .kde/env and put a shellscript in there. The name must end with .sh and the contents should be something like:

  export LANG=en_US.UTF-8

Build a deb package from a vanilla kernel

Sometimes, you want to test a vanilla kernel (i.e. not packaged, but a plain tarball which you got from We are going to use the make-kpkg package for this. To nicely compile and wrap this kernel in a package, take the following steps:

Install the necessary packages:

 $ sudo apt-get install kernel-package libncurses5-dev pkg-config fakeroot

Download your vanilla kernel and unpack it:

 $ cd /usr/src
 $ sudo wget
 $ sudo tar xfj linux-

Use the configuration of the current kernel, and then adapt the configuration to your wishes:

 $ zcat /proc/config.gz > /tmp/.config
 $ sudo mv /tmp/.config .
 $ sudo make-kpkg --rootcmd fakeroot --config menuconfig --initrd --us --uc kernel_image

Note: if you get an error such as: The UTS Release version in include/linux/version.h "" does not match current version: "" then type the following:

 $ sudo cp include/generated/utsrelease.h include/linux/

Then re-run the make-kpkg command. Now install the kernel:

 $ cd ..
 $ sudo dpkg -i linux-image-*deb

Now reboot and select the new kernel!


The included VNC doesn't support compositing very well. Thus running KDE inside VNC will result in a messed up display.

To resolve this, get the Debian packages for TigerVNC. It doesn't include startup scripts but this post on the Ubuntu forum provides some pointers.

Tips and tricks

Smallest possible Debian installation