The apt command has hidden powers beyond the usual install, update, and upgrade; here are 5 of them. These are apt-get and apt-cache subcommands that solve real problems—recovering from broken packages, finding which package owns a file, cleaning up old kernels, and more. Each one is a standard part of Debian/Ubuntu’s APT toolset, so they work on any current system without extra software.
Formula
The calculator above is a pace calculator, not part of the apt article. It computes:
Pace (min/km) = Finish time (minutes) ÷ Distance (km)
Speed (km/h) = Distance (km) ÷ (Finish time (minutes) ÷ 60)
Variables:
t— finish time in minutesd— distance in kilometerspace— minutes per kilometerspeed— kilometers per hour
Worked Example
Using the default values (50 minutes, 10 km):
- Pace = 50 ÷ 10 = 5.00 min/km
- Speed = 10 ÷ (50 ÷ 60) = 10 ÷ 0.8333 = 12.00 km/h
The calculator shows 5.00 min/km and 12.00 km/h.
Background: What APT Actually Is
APT (Advanced Package Tool) is the package management system used by Debian and its derivatives like Ubuntu, Linux Mint, and Pop!_OS. The command you type—apt—is a simplified front-end that combines the most common functions of apt-get (for installing and removing) and apt-cache (for searching and querying). But the front-end hides many subcommands that the older tools expose fully. Knowing them lets you fix problems without resorting to internet searches or reinstalling your OS.
Hidden Power 1: apt-get autoremove — Clean Up Orphaned Packages
When you install a package, APT pulls in dependencies. When you remove the main package, those dependencies often stay behind, orphaned and useless. sudo apt-get autoremove removes them automatically. More importantly, after a kernel upgrade, the old kernel packages become orphans—this command removes them too, freeing disk space and cleaning the GRUB boot menu.
Use it regularly after upgrades:
sudo apt-get autoremove
To see what it would remove without doing it, add --dry-run.
Hidden Power 2: apt-get install -f — Fix Broken Dependencies
Sometimes a package installation fails midway, leaving you with “broken packages” and a system that refuses to install anything else. The fix is sudo apt-get install -f (the -f stands for “fix-broken”). It tells APT to resolve dependency problems by installing missing packages or removing conflicting ones. Run it after any interrupted install, or when you see errors mentioning “unmet dependencies”.
Hidden Power 3: apt-file — Find Which Package Owns a File
You have a command like ffmpeg or a library like libxml2.so, but you don’t know which package provides it. The apt-file command answers that. Install it first with sudo apt install apt-file, then update its index with sudo apt-file update. After that:
apt-file search /usr/bin/ffmpeg
This lists the package(s) that contain that path. It’s invaluable when a program says “command not found” and you need to know what to install.
Hidden Power 4: apt-cache showpkg — See Dependencies and Reverse Dependencies
Before installing a package, you might want to know what it depends on, or what other packages depend on it (reverse dependencies). apt-cache showpkg <package> shows both lists, along with the package’s version and its “provides” entries. For example:
apt-cache showpkg python3
This is more detailed than apt show, which only shows metadata. It’s useful when deciding whether removing a package will break other software.
Hidden Power 5: apt-get download — Download a Package Without Installing
Sometimes you need the .deb file itself—to inspect it, to transfer to an offline machine, or to reinstall later. apt-get download <package> downloads the .deb into the current directory without installing it. It also works with --print-uris to just print the download URL. This is a quick way to get a package for offline installation or for extracting files with dpkg-deb -x.
Common Problems and Misconceptions
“apt vs apt-get” — They’re not different tools; apt is a newer front-end. Some subcommands like apt-file and apt-cache showpkg are not available in apt directly, so you need the older names.
“autoremove deletes my packages” — It only removes packages that were installed automatically as dependencies and are no longer needed. It won’t remove anything you explicitly installed, unless you also removed the package that depended on it.
“I don’t need apt-file; I can use dpkg -S” — dpkg -S works only for files already installed on your system. apt-file searches the entire package repository, including packages you haven’t installed yet.
Comparison: apt vs apt-get vs apt-cache
| Command | Purpose | Hidden power example |
|---|---|---|
apt |
Common operations | apt autoremove |
apt-get |
Install/remove, plus fix-broken | apt-get install -f |
apt-cache |
Query package info | apt-cache showpkg |
apt-file |
Search file ownership | apt-file search |
For most daily tasks, apt is enough. For troubleshooting and advanced queries, the older commands give you more control.
Safety and Best Practices
- Always run
sudo apt updatebefore installing or upgrading, to refresh the package lists. - Use
--dry-run(or-s) before any destructive command likeautoremoveorremoveto preview changes. - When using
apt-get install -f, it may propose removing packages—read the list carefully before confirming. - Do not mix
aptandapt-getin scripts; pick one and stick with it for consistency.
Frequently Asked Questions
Can I undo an apt-get autoremove?
No, there’s no built-in undo. That’s why the dry-run flag exists. If you accidentally remove something, you can reinstall it manually with apt install <package>, but you’ll need to know the name. To avoid surprises, always run sudo apt-get autoremove --dry-run first.
What does “held broken packages” mean?
It means APT has a package that depends on another package whose version doesn’t match what’s available. Usually caused by a partial upgrade or a third-party repository. Run sudo apt-get install -f to fix it, or if that fails, check for held packages with apt-mark showhold.
How do I find out what package provides a command?
Use apt-file search /usr/bin/<command> after installing and updating apt-file. Alternatively, use which <command> to find the path, then dpkg -S <path> if the command is already installed.
Is apt-get download safe?
Yes, it only downloads the .deb file to your current directory—it doesn’t install or modify your system. You can inspect it with dpkg-deb -I or extract it with dpkg-deb -x.
Why doesn’t apt have a showpkg command?
The apt front-end intentionally exposes only the most common subcommands. apt-cache is the full query tool, and apt show is a simplified version. For reverse dependencies, you need apt-cache showpkg.
What’s the difference between autoremove and clean?
autoremove removes orphaned packages (software). apt-get clean removes downloaded .deb files from the cache (/var/cache/apt/archives). Both free disk space, but they target different things.
Related
Formula used
in t | Finish time | min | 50 | 0 in d | Distance | km | 10 | 0 | 100000 out pace | Average pace | min/km | t / d | 2 out speed | Average speed | km/h | d / (t / 60) | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Delete Picture Kik? How to Remove Photos
- What Happens to X Replies, DMs, and Followers After Deletion?
- Data Breaches That Shook the World
- Disable Google Assistant: Turn It Off on Android & Home
- Resin vs FDM Printers for Miniatures: Detail, Durability, Cost
- Are Networked Implants Safe? What If One Fails?