Some useful Pacman commands

siatwe

Simon Weis

Posted on February 1, 2019

Some useful Pacman commands

originally posted on my blog

Here are some Pacman commands that I find quite useful and that may not be known by everyone:

  • This command shows all packages you have installed yourself, except "base" and "base-devel" packages which were installed during the installation of Arch:
pacman -Qei | awk '/^Name/ { name=$3 } /^Groups/ { if ( $3 != "base" && $3 != "base-devel" ) { print name } }'
Enter fullscreen mode Exit fullscreen mode

Shows all installed packages and their individual memory sizes starting with the smallest:

pacman -Qi | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h
Enter fullscreen mode Exit fullscreen mode
  • Uninstall all unneeded packages and their unused dependencies. Quite useful to clean up here and there occasionally:
sudo pacman -Rsn $(pacman -Qdtq)
Enter fullscreen mode Exit fullscreen mode
  • With this command you can display all packages you have received via the AUR. (Lists all foreign packages, which, for most users, means AUR):
pacman -Qqm
Enter fullscreen mode Exit fullscreen mode

Pacman stores fetched packages and does not automatically delete old or uninstalled packages. Of course, this has a few advantages:

  • So you can easily downgrade packages.
  • Packages that have been uninstalled and need to be reinstalled can be installed directly from the cache folder (of course only if there is no newer version in the repos).

However you should clean up this cache here and there so that it does not become infinitely large.
For this there is a script called paccache. It uninstalls all stored package data of the installed and uninstalled packages except the last three. And that should normally be enough:

sudo paccache -r
Enter fullscreen mode Exit fullscreen mode
  • It is also possible to automate paccache. With the following command paccache deletes the cache weekly:
sudo systemctl enable paccache.timer --now
Enter fullscreen mode Exit fullscreen mode
๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
siatwe
Simon Weis

Posted on February 1, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About