37

I noticed while updating my system just how many packages I have installed that I don't recognize.

I tend to think that minimalism is better for security, so I'd like to remove any packages that I'm not using, but this is a bit of a scary task.

Does anybody have a safe method for reviewing and purging unused or bloat packages while obviously making sure not to accidentally remove important dependencies?

I'm on arch btw.

top 20 comments
sorted by: hot top controversial new old
[-] superkret@feddit.org 3 points 5 days ago* (last edited 5 days ago)

Just leave it. Either they do something in the background. Then you'll get issues when they're missing, and you'll never know which package is missing for what.
Or they don't do anything, then they just take up a few MB of disk space.

"Cleaning up" is the most sure-fire way to destroy your OS, and absolutely not worth anyone's time. Trust me, I've made that mistake multiple times.

[-] Termight@lemmy.ml 2 points 5 days ago* (last edited 5 days ago)

Let's just say my last attempt at automated cleanup didn't go well (my desktop disappeared!) Now I’m a collector and keep everything.

[-] MangoPenguin@lemmy.blahaj.zone -1 points 6 days ago

apt autoremove will do it. Just double check what it's removing for obvious problems.

[-] superkret@feddit.org 5 points 5 days ago

apt autoremove does nothing on Arch.

[-] MangoPenguin@lemmy.blahaj.zone 0 points 5 days ago

Well whatever the equivalent is lol, I didn't see the last little line on the post.

[-] superkret@feddit.org 3 points 5 days ago

That's just the thing, though. There is no equivalent on Arch.

[-] MangoPenguin@lemmy.blahaj.zone 3 points 5 days ago

That seems like a rather critical feature to have missing!

[-] superkret@feddit.org 2 points 5 days ago

You can use options in the package manager to show orphaned packages and then decide if you want to remove them.
Removing packages automatically could be argued to be a bad idea in general.

[-] JASN_DE@feddit.org 25 points 1 week ago

That's because a lot of them are dependencies for the packages you actually want to use, and those needed for the system to work as designed.

[-] audaxdreik@pawb.social 18 points 1 week ago* (last edited 1 week ago)

EDIT: More information provided. I disagree with the upvoted comment implying you should leave your system alone because you might break something. You're using Arch, and part of the reason to use Arch is understanding how you built and maintain your system. Understanding how to inspect your system and perform proper maintenance is a crucial part of that. Read and think carefully before taking any actions and make sure any important information is backed up before taking major actions. Without throwing too much further shade, I find it disappointing so many in the community would take that stance and discourage you from pursuing this further.

When I switched to Arch, I started a notebook in Obsidian with a bunch of different information in it, I have a section devoted to Maintenance. Here are a few things I've put in there:

Clean package cache with paccache: https://ostechnix.com/recommended-way-clean-package-cache-arch-linux/

Clean orphaned dependencies: sudo pacman -Rs $(pacman -Qtdq)

Additionally, you can run pacman -Qe to list the packages you yourself have explicitly installed with pacman, or pacman -Qdt to list the packages that are dependencies of other packages. Use pacman -Qm to list packages not found in the official repositories (i.e., things installed through yay). This will allow you to review packages you may have explicitly installed in the past for some reason, but now find you no longer need.

For yay, I'm unsure if I should be using -Yc, -Sc, or -Scc. If anyone has more info with that, I'd appreciate it.

For flatpak: flatpak uninstall --unused

And for journals: journalctl --vacuum-time 7days


That's most of the "automatic" stuff, cruft that can be cleaned out with little to no consequence. Other than that, you'll just have to manually review what you have on your system.

If anyone has other commands or comments on the ones I provided, I'd be happy to accept further advice here as well 😃

[-] nous@programming.dev 4 points 1 week ago

Clean orphaned dependencies: sudo pacman -Rs $(pacman -Qtdq)

In addition to this, or rather before, you can run pacman -D --asdeps package_name to mark a package as a dep. If it is no longer required by something else it will be removed with the above. This can be useful for things that are deps that you installed manually at some point for some reason.

And remember that you can recover from anything, even removing base packages or bootloader ones with a live cd and chroot or using pacman with a different root with the --root /mnt flag to pacman.

Otherwise if your system still boots it is just a matter of following the install instructions for whatever is not working like you did the first time.

[-] audaxdreik@pawb.social 1 points 1 week ago

In addition to this, or rather before, you can run pacman -D --asdeps package_name to mark a package as a dep. If it is no longer required by something else it will be removed with the above. This can be useful for things that are deps that you installed manually at some point for some reason.

Oh, that's some amazing info, thanks!

I had noticed this might be a problem when I was setting something up and tried to install a dependency that was already on the system. It informed me it was being set to explicit and I wondered if it might lead to a situation like that.

[-] nous@programming.dev 3 points 6 days ago

--asdeps also works when installing something to immediately mark it as a dep. Can be useful for non dep packages if you only need it temporarily as it will be removed the next time you purge unused deps.

[-] cravl@slrpnk.net 8 points 1 week ago

For anyone reading this on a Debian-based system, you can get a good start without risking removing anything important like this:

  1. Run apt-mark showmanual, and copy any package names you don't think you need into a list.
  2. Run apt-mark auto <pkg1> <pkg2> ...
  3. Run apt autoremove
[-] pathos@lemmy.ml 0 points 6 days ago

Sorry, just to clarify, <pkg1> etc. will be the ones deleted or not deleted?

[-] greywolf0x1@lemmy.ml 4 points 6 days ago

Those will be deleted as they were picked with the second command

[-] cravl@slrpnk.net 1 points 4 days ago

Like @pathos said, that's the list from the previous step. Because you're autoremoving, it will only remove packages that aren't dependencies of any other packages still installed.

[-] eugenia@lemmy.ml 4 points 1 week ago* (last edited 1 week ago)

These are just dependencies for your packages. However, Arch doesn't automatically clean the downloaded files after installation so that ends up taking space. On my Dell laptop that has only a 64 GB eMMC, the installation package files took and whopping 5 GB of space, sitting there doing nothing. I nuked them (it didn't remove the installed apps and libs, only the already used package files). Run: sudo pacman -Scc

[-] OatPotato@hexbear.net 3 points 1 week ago

You can run pacman -Qe to list explicitly installed packages, beware of packages you may have installed manually as optional dependencies of other packages.

[-] Geodad@lemm.ee 0 points 1 week ago

Assuming you are using something Debian based, you can use:

apt purge (package name)

Followed by:

apt autoremove

this post was submitted on 03 May 2025
37 points (93.0% liked)

Linux

54073 readers
760 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS