What is Apt?
Apt is a powerful package manager that allows you to add and remove programs on your Linux system easily. It works by installing packages from software repositories, which are collections of software made available online. This makes it easy to find and download any open-source program compatible with your distribution (for example, Ubuntu or Debian). What's more, apt makes it easy for developers to create and share their packages - if they have the skills!
If you're just starting with Linux, learning about Apt can be a great way to get comfortable using your system's terminal (the command line interface). Get familiar with apt using the cheat sheet below.
For a quick reference guide, head down at the end of the article to download a PDF copy of this cheat sheet.
Apt cheat sheet
Updating the list of available packages
Command |
Action |
apt-get update |
Keeps you upto date with possible package updates mostly security updates |
Installing packages
Command |
Action |
apt-get install |
Gets your desired package installed |
apt-get install pkg1- |
Removes pkg1 |
Apt-get install pkg1 pkg2+ |
Remove pkg1 and install pkg2 |
apt-get -t dist install pkg |
Installs pkg from distribution dist |
apt-get install pkg=version |
Install a specific version of a package |
apt-get -h |
Gives you the help text |
Remove packages
Command |
Action |
apt-get remove |
Removes a package from your system but leaving the configuration files intact. |
apt-get --purge |
Remove a package completely |
Search
Command |
Action |
apt show bar |
Lists intall status and metadata of package bar |
apt search bar |
Searches for package bar in repository |
apt-file search file |
Searches for a filename in all packages |
apt-file update |
Updates the database of files all packages contain |
apt-file --list bar |
Lists all files included in package bar |
dpkg -L package |
Lists all files installed from package |
dpkg -S file |
Searches for a file name in installed packages |
Upgrading packages
Command |
Action |
apt-get upgrade |
upgrade packages within the same distribution |
apt-get upgrade dist-upgrade |
Upgrade packages within the same distribution as well upgrade to a new distribution |
apt-get -u upgrade |
Show complete list of packages that will be upgraded. |
Upgrading to a new release
Command |
Action |
apt-get -u dist-upgrade |
Upgrades packages and installs new packages |
Removing unused package files: apt-get clean and autoclean
Command |
Action |
apt-get clean |
Removes everything except lock files |
apt-get autoclean |
Removes only packages files that can no longer be downloaded (old files). |
If there is an issue with the cheat sheet, let us know in the comments and we will update it immediately.
Ending ...
Apt is a powerful package manager that allows you to easily add and remove programs on your Linux system. Whether you are new to Linux or an experienced user, knowing how to use Apt can be beneficial for managing your system and keeping it up-to-date with the latest packages. Some useful commands include apt-get update, which updates the list of available packages, and apt-get upgrade, which upgrades existing packages within your system. Additionally, there are several options for removing unwanted packages from your system using the apt command, such as apt-get remove and apt-purge. Finally, you can also use APT with dselect
for more advanced package management tasks. (Lesson for another day).
I hope this was helpful. If it was, support us by subscribing to geekbits.
Thank you!
If you enjoy our content, please consider buying us a coffee to support our work: