Figuring out rarely used packages
Hi there,
I have installed plenty of packages and many of them I don't use anymore. I know how to remove orphans and optional packages, but what about packages that were deliberately installed that I just don't use anymore?
About this post
- Posted
- Archived
- Score
- 117 · 100% up
- Kind
- Text
- ID
- ejyobs
50 comments
Run pacman -Qe to show explicitly installed packages and inspect one by one if you need them in your system. But be careful and read information about package before removing. There should be better way i guess, but that's what i do.
Totally wrong! /jk
or
Then how do I navigate in the fzf preview window?
Thanks for turning me onto
sk!I do the same. It can be a pain doing it manually but I do not know better ways either.
A while ago, I had exactly your question myself and tried to come up with a script to help with hunting down unused packages:
http://ix.io/26ov
I use "pac-atime.sh" as the filename for this script.
The script looks through the file list for each package and looks up the file access times. It then prints a list of all packages sorted by the most recently accessed file in each package.
The idea is to use that list to hunt down the packages that are full of files that are never getting used by anything on the system.
I ran into problems with the idea. There are files that are always getting accessed, even if you don't really use anything in the package. An example for that are ".desktop" files for the applications menu of the desktop environment. Those are always read when the desktop environment starts up.
I tried to prepare a filter system for that problem. Right now it only filters out directories and desktop files. I don't know what other files there are that will make a problem.
To get some more details about an interesting package, the script accepts package names as arguments. It will then show the file details of the package and will show which entries were ignored by the file filter.
The other problem is that I'm a bit unsure about how the default "relatime" mount option for filesystems influences things. "Relatime" makes it so file access times are not always getting updated. In that sense, you can't fully rely on the access time, but it seems it still gets updated at least once a day. It should be good enough to make this script here useful.
And then there's people like me who change everything to noatime. Very cool idea though!
atime is actively harmful for filesystem health and performance; I wouldn't blame you :P
Thank you! I have been wanting exactly this. I forgot about ext4 access time. I was going to resort to parsing out ps aux but that would miss very transient processes. I thought maybe some bpf script could be used but that was overly complicated.
I wrote this command some time back.
{(comm -23 <(yay -Qqe | sort) <({(pactree -u -d 1 base)&&(yay -Qqg base-devel);} | sort))&&(comm -23 <(yay -Qqtt | sort) <(yay -Qqt | sort));} | sort | uniq
It lists non-base explicitly installed packages and optional dependencies. Note that it will require 'pactree' and 'yay' packages. Using 'yay' helps to list AUR packages as well.
Pacman still does handle (install, remove) AUR packages. If you install them manually you will clearly see that. Yay just fetches for AUR packages from the website and does some dependency calculations.
Oh, I see. Didn't know about this XD, thanks!
How so?
I meant to say it will also list the AUR packages installed via 'yay'. Didn't mean to point out to all the AUR packages installed. Thanks for pointing out :)
You could perhaps list the files owned by each package (
pacman -Q<something>, sorry forgot which option it is) and combine that withstatto get latest file access time.pacman -Qolists the package corresponding to a file. Is that what you meant?Mnemonics!
ofor owns (to find package that owns this specific file)lfor list (to list all files that belong to a<pkgname>)should be
lsinceAgree with pacman -Qe.
Also check if you can view history for sudo pacman installs. May help give context and jog your memory of when/why. Likely the older installs further back in history will be some of that cruft.
pacman -Qi gives installation date so there is no need to dig logs for that
I thought about making a script that sorted based on atime as someone else in this thread did. In addition to the problems they encountered, another is that a package that is updated but not used will appear to have been accessed. So to know how long it's truly been, you would have to have a pacman hook that notes atimes before and after an update and the tool would have to keep an external database of these. It's complicated.
Perhaps you should visit this link https://bbs.archlinux.org/viewtopic.php?id=223516
Deleted before we saved it.