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. I ran the commands on Ubuntu 25.04 and kept real output below.
Tested on: Ubuntu 25.04 (Plucky Puffin); kernel 6.14.0-37-generic; amd64.
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 |
| Obsolete packages | Installed version missing from all apt sources | apt list '?obsolete' then review—see remove obsolete packages |
| 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.
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 |
| Post-release-upgrade stale packages | Obsolete packages |
| Uninstall a specific app you chose to remove | How to remove software on Ubuntu |
Prerequisites
- Ubuntu 22.04 LTS, 24.04 LTS, or newer (25.04 tested)—see check Ubuntu version.
- sudo for remove, purge, and cache commands.
- Read-only listing works without root; simulations still benefit from
sudowhen locks matter.
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:
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 |
| unusedpkg (GitHub script) | Third-party | Ranks by file idle time; Ask Ubuntu links it—read the script and verify timestamps before any apt remove |
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 |
| Freed cache but apps still huge | Cache ≠ installed packages | Use list installed packages size sort; remove apps you do not need |
| Many packages still “unused” after autoremove | Confusing unused with obsolete | apt list '?obsolete'—see obsolete guide |
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.

