The Awesome APT Package

The first package I would recommend everyone to 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 I find incredibly useful:

apt-get update: to refresh sources

apt-cache search <package-name>: to search for packages containing <package-name>and show their descriptions

apt-cache pkgnames <pkg-prefix>: to search for packages with names starting with <pkg-prefix>

apt-get -d install <pkg-identifier>: to download the package .deb file to /var/cache/apt/archives/

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

Cache

apt-cache stats to show statistics about your all sources combined, including number of packages

apt-cache pkgnames to list all available packages; will take a while and may pause halfway while cataloging on-screen

apt-cache pkgnames com.package.name to list packages starting with PackageName; doesn’t show descriptions

apt-cache search com.package.name to search for packages containing PackageName and show their short descriptions

apt-cache show com.package.name to show the control file for PackageName

apt-cache showpkg com.package.name to list dependencies required for PackageName and reverse dependencies on PackageName including uninstalled ones


Refreshing sources

apt-get update to refresh sources


Upgrading and Installing

apt-get upgrade to update packages without automatically removing/installing anything to satisfy conflicts/dependencies

apt-get dist-upgrade to update packages by automatically removing conflicts and installing dependencies

apt-get install com.package.name to 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 to 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 to 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 to uninstall a package without removing configuration files

apt-get remove --purge com.package.name to uninstall a package and remove configuration files (these are not preference files, which will still remain)

apt-get purge to remove any remaining config files for uninstalled packages

apt-get autoremove to 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 to only clean up old .deb files that can no longer be downloaded and are largely useless

apt-get clean to clean up all .deb files in /var/cache/apt/archives

apt-get check to check that there are no broken dependencies

Hey! Thanks for reading :P I just want to let you know that if you enjoyed this, you might also like this post on Sorting.

ABOUT THE AUTHOR RSS Feed Icon

I'm Bobby Yan, a programmer, music lover and web developer. I am currently working on IB Notes, a website with useful and concise study guides and notes for IB students. I have also built the Spanish Vocabulary Builder iOS app to help Spanish learners.

If you enjoyed this article, you should follow me on Twitter or sign up to get an email whenever I write something new:

Share this article with your friends: