• Edit
  • Delete

apt / dpkg cheatsheet

Fix broken/aborted installation

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

Reconfigure

  • dpkg-reconfigure package

No questions asked / use old config:

  • ??

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

apt upgrade; apt-get -o Dpkg::Options='--force-confdef --force-confold' dist-upgrade

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

http://askubuntu.com/questions/17823/how-to-list-all-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
      w3m.postrm
      w3m.preinst
      w3m.prerm