| Tested on | Ubuntu 25.04 (Plucky Puffin) |
|---|---|
| Package | apt |
| Applies to | Ubuntu, Debian, Kali Linux, Linux Mint, Pop!_OS, Raspberry Pi OS, elementary OS, Zorin OS, Parrot OS, MX Linux |
| Privilege | sudo or root |
| Scope | Remove unused packages on Ubuntu with apt autoremove for orphaned dependencies, apt clean and autoclean for download cache, purge rc config leftovers, protect apps with apt-mark manual, and prune old Snap revisions—without confusing unused. |
After you uninstall software or finish an upgrade, Ubuntu often still has leftovers: dependency packages nothing needs anymore, downloaded .deb files in the apt cache, configuration directories from purged apps, or old Snap revisions. The phrase “unused packages” shows up in forum posts and upgrade prompts, but it does not always mean the same thing.
This guide separates those cases and shows the safe, official cleanup path first—apt autoremove—plus cache cleanup, rc config purge, protecting apps with apt-mark manual, and optional usage-based tools. Compare what you keep against must-have Ubuntu apps before you purge desktop utilities you still open weekly.
autoremove), obsolete (post-upgrade /now packages), apt cache (downloaded .deb files), and rc configs are four different cleanups. Mixing them up is how people delete apps they still open every day—read the comparison table before bulk commands.
Unused vs obsolete vs cache vs rc
| Term | What it is | Safe default command |
|---|---|---|
| Unused dependencies | Auto-installed packages nothing depends on | sudo apt autoremove |
| APT download cache | .deb files in /var/cache/apt/archives/ |
sudo apt autoclean or sudo apt clean |
rc leftovers |
Config files after apt remove |
sudo apt purge packagename |
| Old Snap revisions | Disabled snap builds kept for rollback | sudo snap remove name --revision=REV |
| Rarely used apps (heuristic) | Low popularity-contest score—not orphan-safe | Manual review only |
Ask Ubuntu guidance on autoremove and safely removing unused packages both stress the same point: APT cannot know which applications you still want—it only tracks automatic vs manual install flags and dependency graphs (see stress command).
What do you want to clean?
| Goal | Jump to |
|---|---|
| Remove orphaned dependency packages (main task) | apt autoremove |
| Preview before deleting anything | Dry-run autoremove |
| Stop autoremove from deleting an app you need | Protect with apt-mark manual |
Free disk from downloaded .deb files |
apt clean and autoclean |
| Remove leftover config after uninstall | Purge rc packages |
| Drop old Snap revisions | Prune disabled Snap revisions |
| Find rarely touched packages (advanced) | popularity-contest |
| Uninstall a specific app you chose to remove | How to remove software on Ubuntu |
Prerequisites
Related: apt command, dpkg command, list installed packages.
Remove unused dependencies with apt autoremove
When you install a package, APT pulls in dependencies and marks them automatically installed. If you later remove the parent app, those libraries may sit unused. apt autoremove removes automatic packages no other installed package still requires.
Preview first (see next section), then run:
sudo apt autoremoveAdd --purge to drop configuration files for those dependencies too:
sudo apt autoremove --purgeOn the test host, a dry-run proposed removing one orphaned library after a PPA package was removed earlier:
The following packages will be REMOVED:
libtorrent-rasterbar2.0
0 upgraded, 0 newly installed, 1 to remove and 31 not upgraded.With --purge, the same simulation showed a Purg line instead of Remv—configs go with the package.
autoremove is the cleanup step Ubuntu offers after apt remove when it prints “The following packages were automatically installed and are no longer required.” Running it regularly after uninstalls is enough for most desktops and servers.
Preview with dry-run first
Never confirm autoremove blind on a machine you care about. Simulate:
sudo apt-get -s autoremoveOr with purge:
sudo apt-get -s autoremove --purgeThe -s flag means simulate—no packages change. Read every name in “The following packages will be REMOVED”.
If the list is empty:
0 upgraded, 0 newly installed, 0 to remove and 31 not upgraded.That is a healthy sign—nothing APT considers an orphaned automatic dependency right now.
Protect a package from autoremove
Ask Ubuntu: safely removing unused packages describes a common trap: autoremove proposes deleting an application you still use because APT marked it automatic—for example when it was installed as a dependency of a metapackage you removed, or a GUI installer set the wrong flag.
Mark a package manual so autoremove skips it:
sudo apt-mark manual packagenameVerify:
apt-mark showmanual | grep -i packagenameList packages still marked automatic (candidates for autoremove when nothing needs them):
apt-mark showauto | headOn the test host, 324 packages were manual and 2256 automatic—most of your system is dependencies, which is normal.
To mark a dependency automatic again (only when you are sure):
sudo apt-mark auto packagenameClear the APT download cache
These commands do not remove installed programs. They delete cached .deb files APT downloaded during installs and upgrades.
Check cache size:
Summarize directory size with du -sh; the df and du compares human-readable totals and sorting large folders.
du -sh /var/cache/apt/archives/On the test host that reported 627M.
autoclean — delete outdated cache files only
Removes .deb files that are no longer downloadable from your configured sources (superseded versions):
sudo apt autocleanSimulation showed lines like:
Del mongodb-org-server 8.0.26 [43.1 MB]
Del mongodb-mongosh 2.8.3 [64.3 MB]
Del mongodb-database-tools 100.17.0 [60.7 MB]clean — wipe the entire download cache
Deletes all package files from /var/cache/apt/archives/ (except lock files):
sudo apt cleanSimulation output:
Del /var/cache/apt/archives/* /var/cache/apt/archives/partial/*autoclean routinely; use clean when you need maximum space back and do not mind re-downloading .deb files on the next upgrade. Neither replaces autoremove.
Purge rc configuration leftovers
After apt remove, packages can remain in rc state—removed, but config files linger:
dpkg -l | grep '^rc'Sample rows on the test host:
rc apg 2.2.3.dfsg.1-7 amd64 Automated Password Generator
rc cups-pk-helper 0.2.6-2.1 amd64 PolicyKit helper to configure cups
rc evolution-data-server 3.56.0-1 amd64 evolution database backend serverCount:
dpkg -l | grep -c '^rc'That returned 26 entries—small on disk, but easy to clean.
Purge one:
sudo apt purge apgBulk purge after review:
dpkg -l | awk '/^rc/{print $2}' | xargs -r sudo apt purge -yThis is config cleanup, not dependency orphan removal.
Prune old Snap revisions
Snap keeps older disabled revisions for rollback. They are not apt packages and autoremove does not touch them.
List disabled revisions:
snap list --all | awk '/disabled/{print $1, $2, $3}'Example lines:
firefox 152.0.1-1 8521
gnome-42-2204 0+git.837775c-sdk0+git.7b07595 226
mesa-2404 25.0.7-snap211 1165The test host had 7 disabled revisions.
Remove one revision (keep the current enabled build):
sudo snap remove firefox --revision=8521Repeat per line, or script carefully—never remove the revision you are currently running.
Optional: find rarely used packages
popularity-contest / popcon-largest-unused
The popularity-contest package reports which files on your system were accessed recently. popcon-largest-unused lists packages with low participation scores—a hint for manual review, not a safe bulk-delete list.
Install:
sudo apt install popularity-contestGenerate the data file (required once):
sudo popularity-contest | sudo tee /var/log/popularity-contest > /dev/nullRun the report:
popcon-largest-unused | head -15Example output:
63459 libclang-cpp18
37925 vim-runtime
36607 libclang1-19
17870 libc6-dbg
16788 locales
14892 ieee-data
14691 crash
12757 memtest86+
12614 gdb
12472 libgtk-4-bin
9936 firmware-sof-signed
9244 m17n-db
8210 bpftrace
7345 papers
5504 orcaHigh numbers mean more popularity-contest votes—not “safer to delete.” Removing locales or libc6-dbg because they appear here would break the system.
Legacy and third-party tools
| Tool | Status on Ubuntu 25.04 | Notes |
|---|---|---|
| deborphan | Not in default repositories | Historical orphan finder; Ask Ubuntu mentions it—prefer autoremove today |
| gtkorphan | Not in default repositories | Old GUI orphan tool; discontinued on recent Ubuntu |
popcon-largest-unused, deborphan, or unusedpkg output straight into xargs apt remove. Ubuntu cannot infer which packages you still need—review each name and check apt-cache rdepends packagename when unsure.
Troubleshooting
| Symptom | Likely cause | What to try |
|---|---|---|
autoremove wants to delete an app you use |
Package marked automatic | sudo apt-mark manual packagename |
autoremove removes almost nothing |
No orphaned automatic deps | Normal—run after uninstalling larger apps |
autoclean / clean did not free much space |
Cache already small | Check du -sh /var/cache/apt/archives/; look at Snap, logs, old kernels |
rc entries return after purge |
Metapackage or reinstall pulled configs | sudo apt purge again; check for snap/flatpak duplicate |
popcon-largest-unused warns missing file |
No survey log yet | sudo popularity-contest | sudo tee /var/log/popularity-contest |
deborphan not found |
Dropped from current Ubuntu releases | Use apt autoremove and manual review |
References
- apt(8) — Ubuntu man page
- apt-mark(8) — Ubuntu man page
- Package management — Ubuntu Server documentation
- popularity-contest(8) — Ubuntu man page
- snap(8) — Ubuntu man page
Summary
On Ubuntu, remove unused dependency packages with sudo apt autoremove (optionally --purge) after you apt-get -s autoremove and read the list. That is what upgrade wizards and Ask Ubuntu cleanup answers mean by unused packages—not every program you have not opened lately.
apt autoclean and apt clean only shrink the download cache under /var/cache/apt/archives/—they do not uninstall applications. Purge rc configs separately, prune disabled Snap revisions when you need space, and use apt-mark manual when autoremove targets software you still rely on. For packages left behind after a release upgrade, use the obsolete packages guide instead of autoremove alone. If you are moving between interim releases, plan the hop with upgrade Ubuntu 25.04 to 26.04 LTS before you chase cleanup.
Frequently Asked Questions
What does apt autoremove do on Ubuntu?
apt autoremove uninstalls packages APT marked as automatically installed when nothing else depends on them anymore—typically libraries left behind after you removed an application. It does not remove packages you explicitly installed unless they were wrongly marked automatic.
Is apt autoclean the same as autoremove?
No. autoclean deletes outdated .deb files from /var/cache/apt/archives that can no longer be downloaded. autoremove uninstalls installed packages. clean wipes the entire apt download cache. None of these three commands do the same job.
How do I preview what autoremove will delete?
Run sudo apt-get -s autoremove or sudo apt -s autoremove before confirming. Read every package name in the simulation output—autoremove can remove a dependency another tool still needs if APT dependency tracking disagrees with how you use the system.
Why does autoremove want to remove an app I still use?
APT may have marked the package automatic—common when it was pulled in as a dependency or installed through a metapackage you later removed. Run sudo apt-mark manual packagename to protect it, then rerun autoremove.
What is the difference between unused and obsolete packages?
Unused (autoremove) means auto-installed dependencies nothing requires anymore. Obsolete means the installed version is no longer in any configured apt repository—common after release upgrades. See remove obsolete packages on Ubuntu for ?obsolete cleanup.
What are rc packages and should I purge them?
rc means the package was removed but configuration files remain in /etc. They are not running software—purge them with sudo apt purge packagename or bulk purge rc names to reclaim a small amount of disk space.
Is deborphan still available on Ubuntu?
deborphan is not in the Ubuntu 25.04 repositories and is largely unmaintained. Prefer apt autoremove for dependency cleanup and manual review with apt-mark showmanual for packages you care about.
How do I remove all unused dependencies at once?
Run sudo apt autoremove after reviewing the list, or sudo apt autoremove --purge to drop config files too. Combine with sudo apt autoclean for cache and purge rc leftovers separately—there is no single safe command that removes every kind of leftover on a production system without review.

