Intermediate · 8 min · practise every command in the built-in terminal

dpkg — Debian Package Tool

apt is a friendly wrapper; dpkg is the lower-level tool that actually installs .deb files. You'll reach for it when you have a package file directly, or need details apt doesn't show as easily.

Install a local .deb file

sudo dpkg -i package.deb

If it fails due to missing dependencies:

sudo apt install -f     # "Fix" — installs missing dependencies

List all installed packages

dpkg -l
dpkg -l | grep python

Get info about an installed package

dpkg -s curl

List files installed by a package

dpkg -L curl

Find which package a file belongs to

dpkg -S /usr/bin/ls

Packages record where a file really is. On Debian 13 /bin is only a link to /usr/bin, so dpkg -S /bin/ls finds nothing — ask about /usr/bin/ls (which ls shows the real path).

Remove a package with dpkg

sudo dpkg -r package-name         # Remove
sudo dpkg -P package-name         # Purge (remove + configs)

apt vs dpkg

aptdpkg
Resolves dependenciesYesNo
Downloads from reposYesNo (needs local .deb)
Use caseDay-to-day package managementInstalling a downloaded .deb, low-level inspection

Practice tasks

  1. List all installed packages with dpkg
  2. Find out which package owns the file /usr/bin/ls
  3. Get detailed info about the installed curl package
  4. List all files installed by the curl package

Commands in this lesson

Package Management