• Edit
  • Delete

apt / dpkg cheatsheet

Fix broken/aborted installation

  • apt-get update --fix-missing
  • dpkg --configure -a
  • apt-get install -f


  • dpkg-reconfigure package

No questions asked / use old config:

  • ??

apt upgrade unattended, use default answers (no) or fallback to old config

export DEBIAN_FRONTEND=noninteractive; apt update; apt --assume-yes -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" dist-upgrade: apt autoremove

  • DEBIAN_FRONTEND=noninteractive
  • --assume-yes
    • Answer questions with yes (Do you want to upgrade...)
  • -o "Dpkg::Options::=--force-confdef"
    • Use default package config for new packages
  • -o "Dpkg::Options::=--force-confold"
    • Use existing config for already installed packages (to not overwrite the existing config!)


  • export DEBIAN_PRIORITY=critical

    • ask only absolutely necessary questions

  • apt -q

    • Quiet, don't ask questions


Find out if a package is installed

  • dpkg -s packageName

Install a package manually

If you installed an older version make sure to set the package on "hold" (see below)

Prevent a package from beeing updated (Hold)

  • sudo apt-mark hold packageName
  • Deprecated: echo "packageName hold" | dpkg --set-selections

Revert hold with

  • apt-mark unhold packageName

Uninstall a package manually

  • dpkg -r packageName

Information about a .deb package

Basic information

  • dpkg-deb -I packageName

List of files

  • dpkg-deb -c packageName

Try to install dependencies automatically

  • dpkg -i packageName_2.48.3-1ubuntu1_amd64.deb
    • dpkg: dependency problems...
  • apt-get -f install

Force installation even if dependencies are unmet

  • dpkg -i --force-depends packageName_2.48.3-1ubuntu1_amd64.deb

Get a list of manually installed packages


  • zgrep -hE '^(Start-Date:|Commandline:)' $(ls -tr /var/log/apt/history.log*.gz ) | egrep -v 'aptdaemon|upgrade' | egrep -B1 '^Commandline:'

Fix errors in pre/post scripts

  • The scripts are in /var/lib/dpkg/info
  • Example for w3m
    • w3m.postinst

Re-Install all Packages

  • sudo aptitude reinstall '~i'