Install

  • Install a package from a lower-priority repository, like the backport repository:

    $ apt-get -t squeeze-backports install my-package
  • Force reinstallation of a package:

    $ apt-get -d --reinstall install my-package
    $ dpkg --install --force-confmiss /var/cache/apt/archives/my-package.deb

Upgrade

  • Upgrade package listing and metadata:

    $ sudo apt update
  • Force yes so that package maintainer’s version of config files always prevails:

    $ sudo apt upgrade -y --force-yes

Holding

  • Hold a package with either dpkg or aptitude:

    $ echo "kdenlive hold" | dpkg --set-selections

    or:

    $ aptitude hold kdenlive
  • Unhold a package:

    $ echo "kdenlive install" | dpkg --set-selections

    or:

    $ aptitude unhold kdenlive
  • List holded packages:

    $ dpkg --get-selections | grep hold

Uninstall

  • Uninstall a package thoroughly (both program files and configuration):

    $ apt-get remove --purge my_package
  • Force removal of a package while ignoring all dependencies:

    $ dpkg --remove --force-depends libsomething
  • Remove orphaned packages:

    $ deborphan | xargs apt-get -y remove --purge

Clean-up

  • Clean aptitude local cache:

    $ apt-get clean
  • Remove dpkg lock file:

    $ rm /var/lib/dpkg/lock