
Follow ZDNET: Add us as a preferred source on Google.
ZDNET's key takeaways
- Apt is more than just a software installer.
- The Debian/Ubuntu package manager can do much more.
- With these commands at your disposal, apt becomes more powerful.
I've used Debian/Ubuntu-based distributions for decades. Because of that, I'm quite familiar with the Apt package manager. I've always found this command-line tool to be quite easy and efficient to use.
Also: How to install Linux applications from the command line
Although you can get away with just using the basic commands, there's much more to Apt than just install, remove, update, and upgrade. In fact, there are several lesser-known options for Apt, and I'm going to introduce you to them.
1. apt list
If you want to know which packages are accessible, installed, and upgradeable, you can use apt list. If you want to get a complete list of packages, run:
apt list
That will show every available package, whether installed or not. You probably won't think that's very useful, so you'll want to use a few handy options, such as:
- apt list –upgradable – lists all installed applications that can be upgraded.
- apt list –installed – lists all installed applications
2. apt purge
When you remove a package with sudo apt remove
The purge option works like this:
sudo apt purge
Also: I install these 11 apps on every new Linux system, and you should, too – here's why
Where
3. apt search
You might want to check whether any app you want to install is available in the default Apt repository. For example, you might want to install Spotify, and you're not sure if you can install it with Apt. To find out, issue the command:
apt search spotify
You probably won't see Spotify listed. Instead, you'll see a number of alternative options. Once you've run that command, you can either install the app in question or you can move on to another package manager to install the software. In the case of Spotify, it can be installed via Flatpak or Snap.
One thing to keep in mind is that the results of an apt search can be fuzzy. If you want to view only exact matches, the command would be:
apt search spotify | grep -i -w spotify
The above command would run the standard fuzzy search, but would limit the results to only the search string used in the grep command.
4. apt show
When you want to view the details about a package, you use apt show, which displays author, download size, dependencies, source repository, conflicts, and more. This option can be handy when you want to know what's being installed before running the installation command.
Also: Installing apps on Linux? 4 ways it's different than any other OS – and mistakes to avoid
To use apt show, the command is:
apt show
For example, you could issue:
apt show geary
The above command would display all of the details about the Geary email application.
5. apt autoremove
Sometimes, when you uninstall an application, it might leave behind dependencies that are no longer needed and take up space. After removing several apps, the collection of unneeded software can get rather large.
To get rid of all of those packages that are no longer needed, issue the command:
sudo apt autoremove
6. apt clean
Apt keeps cached files, which can also take up room on your drive. Before you remove them, understand that the cache files serve the purposes of permitting rollbacks, effectively handling dependencies, enabling offline installation, speeding up package installations, and saving space.
However, if space is an issue, you can clear the Apt cache with the commands:
sudo apt clean
sudo apt autoclean
7. apt mark
There might be an occasion when you don't want an application to upgrade. For instance, you might have read that a particular upgrade breaks a feature you need. If you run apt upgrade, that application is going to be upgraded.
To avoid that, you can mark an app so that it's blocked from being upgraded. Let's say you don't want VirtualBox to be upgraded. To do that, the command would be:
sudo apt-mark hold virtualbox
You can view a list of all held packages with:
sudo apt-mark showhold
If you want to unhold a package, the command is:
sudo apt-mark unhold
8. apt download
Let's say you want to download a package but not install it yet. You might want to download the .deb file to be installed on a machine that doesn't have access to the external network (say, for security purposes), but you still need that app. You can download the installer file and move it to the air-gapped machine.
Also: Snap vs. Flatpak: How to decide which Linux package manager is right for you
Let's say you want to download the VirtualBox installer file. To do that, the command would be:
sudo apt download virtualbox
The .deb file will be saved to the current working directory.

