Skip to content

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?

117 points49 comments
Open on Reddit
About this post
Posted
Archived
Score
117 · 100% up
Kind
Text
ID
ejyobs

Author

5
posts
1
comments
2
media
View profile

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.

52 points

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.

34 points

And then there's people like me who change everything to noatime. Very cool idea though!

10 points

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.

2 points
unknown author10 hidden

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.

9 points

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.

13 points
unknown author

Oh, I see. Didn't know about this XD, thanks!

3 points

Using 'yay' helps to list AUR packages as well.

How so?

4 points
unknown author6 hidden

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 :)

1 points

You could perhaps list the files owned by each package (pacman -Q<something>, sorry forgot which option it is) and combine that with stat to get latest file access time.

6 points

pacman -Qo lists the package corresponding to a file. Is that what you meant?

4 points

Mnemonics!

  • o for owns (to find package that owns this specific file)
  • l for list (to list all files that belong to a <pkgname>)

should be l since

list the files owned by each package

3 points

Agree 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.

3 points

pacman -Qi gives installation date so there is no need to dig logs for that

3 points

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.

1 points
unknown author

Deleted before we saved it.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.