Screenshot of fzf with the preview on of a list of Linux packages being filtered by the keyword electron.

List Packages That Depend On Another Package with Pacman

  • Adam Douglas

Maintaining a clean Linux system is always a challenge, but it is doable. One such task that I honestly do not enjoy doing is removing packages that are no longer required, or wanted without breaking another package. The issue with this task is that it requires running multiple commands in order to determine if a given package can be removed safely. I’ve found the solution I’ve been using works quite well with my workflow, and I hope it may be of help for you as well.

Crafting an Alias

The solution I’ve found is by creating an alias command that will allow to filtering packages, and then see a preview of dependant packages of a specific package. The alias command requires the use of either GNU Bash or fish on an Arch Linux based system as it uses pacman, and pactree to fetch the necessary information. The results are displayed using fzf.

The package required for pactree is pacman-contrib , and fzf package name is the same name as the command.

I would like to say I came up with this command myself, but I did not. The unfortunate part is I have no idea who originally did, let alone recall the minor tweaks I did. Too much time has passed to remember the details.

Bash Alias

Here is how to implement the alias command I named pkgdep, short for package dependencies by editing the Bash user configuration file, and adding an alias command as desired to the file.

$ nano ~/.bashrc
alias pkgdep="pacman -Qq | fzf --preview 'pactree -lur {} | sort' --layout reverse --bind 'enter:execute(pactree -lu {} | sort | less)'"

Fish Alias

Aliases in fish are called functions, and are each stored separately in their own file. We will create a new function called pkgdep (package dependencies) by following the below instructions.

$ nano ~/.config/fish/functions/
function pkgdep --description 'package depedencies'
 command pacman -Qq | fzf --preview 'pactree -lur {} | sort' --layout reverse --bind 'enter:execute(pactree -lu {} | sort | less)';


Arch User Repository (AUR) helpers can be used by replacing "pacman" command as desired (e.g. pikaur, yay, etc.).


Simply run the new alias command in the console or terminal, and begin the search. The left-hand side will be a list of all the packages installed on the system, and the right is the packages that are required for the selected package.

$ pkgdep

The screenshot below shows a user searching for “electron”, and then selecting the “electron” package to see on the right what packages require it.

Screenshot of results from running pkgdep alias command.

This is post 74 of 100, and is round 2 of the 100 Days To Offload challenge.

    • fix tag bash to BASH
    • change topic
    • Add missing image alt attribute
    • change 100DaysToOffload message
    • fix broken links