APT Package

First package everyone should install is APT 6 Transitional (deb file here).

Note: you could install .deb packages by using the dpkg -i <path-to-deb-file> command.

Once you’ve done that, you can start playing with apt-cache and apt-get.

Here is a list of commands that you’ll probably find useful:

apt-get update
  • refresh sources
apt-cache search <package-name>
  • search for packages containing <package-name> and show their descriptions
apt-cache pkgnames <pkg-prefix>
  • search for packages with names starting with <pkg-prefix>
apt-get -d install <pkg-identifier>
  • download the package .deb file to /var/cache/apt/archives/

At any rate, you could always use the --help flag to bring up the full list of commands, but I present you with a slightly more comprehensive list of common commands below: (credits to this reddit post by u/Secretss)

Cache

apt-cache stats
  • show statistics about your all sources combined, including number of packages
apt-cache pkgnames
  • list all available packages; will take a while and may pause halfway while cataloging on-screen
apt-cache pkgnames com.package.name
  • list packages starting with PackageName; doesn’t show descriptions
apt-cache search com.package.name
  • search for packages containing PackageName and show their short descriptions
apt-cache show com.package.name
  • show the control file for PackageName
apt-cache showpkg com.package.name
  • list dependencies required for PackageName and reverse dependencies on PackageName including uninstalled ones

Refreshing sources

apt-get update
  • refresh sources

Upgrading and Installing

apt-get upgrade
  • update packages without automatically removing/installing anything to satisfy conflicts/dependencies
apt-get dist-upgrade
  • update packages by automatically removing conflicts and installing dependencies
apt-get install com.package.name
  • install or update a package or packages; separate package names with a space; doesn’t work as a reinstall
apt-get install com.package.name=version.number
  • install a specific version of a package if it’s available; only works if the package isn’t already installed at the requested version; works for downgrading
apt-get -d install com.package.name
  • download a package to /var/cache/apt/archives without installing; only works if the package isn’t already installed (or at the same version requested as indicated with ‘=’)

Removing and Purging

apt-get remove com.package.name
  • uninstall a package without removing configuration files
apt-get remove --purge com.package.name
  • uninstall a package and remove configuration files (these are not preference files, which will still remain)
apt-get purge
  • remove any remaining config files for uninstalled packages
apt-get autoremove
  • remove dependencies that were installed for another package that has since been uninstalled and thus are no longer needed

Cleaning and Checking

apt-get autoclean
  • only clean up old .deb files that can no longer be downloaded and are largely useless
apt-get clean
  • clean up all .deb files in /var/cache/apt/archives
apt-get check
  • check that there are no broken dependencies

Hey, kudos for making it this far! If you've liked this, you might also like tmux Cheatsheet and Shortcuts.