Cheat Sheet Library

apt & dpkg (Debian/Ubuntu) Cheat Sheet

apt installs packages from repositories and handles dependencies. dpkg works with individual .deb files. Most commands need sudo.

  • 40 entries
  • 7 sections
  • Updated
  • Click a command to see all its options

40 entries

On this page

Everyday #

CommandAction
Refresh the package lists (always do this first)
Upgrade installed packages
Upgrade and allow adding / removing dependencies
Install
Install several packages without the confirmation prompt
Install a local .deb with its dependencies
Remove (keeps config files)
Remove including config files
Remove dependencies that are no longer needed
Reinstall

Search & Info #

CommandAction
Search packages
Package details (version, size, dependencies)
All installed packages
Packages with updates available
Installed vs available version and which repo it comes from
Dependencies
What depends on this package

dpkg (low level) #

CommandAction
Install a .deb (does not fetch dependencies)
Remove
List installed packages
Check whether something is installed
Files installed by a package
Which package owns this file
Finish interrupted installs

Fixing Problems #

CommandAction
Fix missing or broken dependencies
Resume after a crash or interrupted install
Delete all downloaded .deb files
Delete only outdated .deb files
Freeze a package at its current version
Unfreeze
Packages you installed yourself

Repositories #

Path / commandUse
/etc/apt/sources.listMain repository list (older format)
/etc/apt/sources.list.d/*.sourcesExtra repos (deb822 format, Debian 12+ / Ubuntu 24.04+)
/etc/apt/keyrings/Place for repository signing keys
Add a PPA (Ubuntu only)
Upgrade to the next Ubuntu release

Other Package Formats #

CommandAction
Install a Snap (Ubuntu)
/ List / update snaps
Install a Flatpak
Update Flatpaks

Tips #

  • A quick full update: sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y.
  • "Could not get lock"? Another update is still running. Wait for it instead of deleting lock files.
  • Automatic security updates: sudo apt install unattended-upgrades.