Maintaining Arch Linux Packages

Arch linux uses the package manager Pacman, which keeps the system up to date by synchronizing package lists with the master server. This allows the user to install packages with all dependencies using a simple command. Pacman is written in C programming language and uses bsdtar for packaging.

Installing Packages

# pacman -S package_name1 package_name2 ...

Removing Packages with dependencies

# pacman -Rs package_name

Sometimes pacman needs to be forced closed if there is a stuck process preventing new commands

ps aux | grep pacman
ps aux | grep yay

If those commands output any lines then close those processes by entering
Take note of any pid numbers from the aux output

sudo kill -9 <PID>

If no pacman instances are running remove the stale lock file

sudo rm /var/lib/pacman/db.lck

Basic System Cleanup

Remove old backup cache.
Pacman keeps a cache of all downloaded packages. To remove all but the last 3

sudo paccache -r

Remove uninstalled orphans

This will show the libraries that are no longer in use by any installed package

sudo pacman -Qtdq

To remove those libraries

sudo pacman -Rns $(pacman -Qtdq)

Remove leftover config files

When packages are uninstalled using -Rns they may leave leftover files in /etc. You can find leftover .pacsave or .pacnew files

sudo find /etc -type f \( -name "*.pacsave" -o -name "*.pacnew" \)

To clean the aur cache

yay -Sc

Periodic maintenance
Can safely run every few months

sudo paccache -r
sudo pacman -Rns $(pacman -Qtdq)
Leave a Reply 0

Your email address will not be published. Required fields are marked *