# Package Management on Arch

# Common pacman Commands

Install packages from Arch standard repository

pacman -S <packagename>

+++

Remove packages and its dependencies that are not required by other packages

pacman -Rs <packagename>

+++

List installed packages

pacman -Qs

+++

Query installed packages

pacman -Qs <packagename>

+++

Get detailed info of a package (e.g. installation date)

pacman -Qi <packagename>

+++

Update all packages from standard repo in system

pacman -Syu

Arch does not support partial upgrades (or upgrading of single packages), meaning that any upgrades need to be performed system-wide.

# Common yay commands

Install packages from AUR repository

yay -S <packagename>

+++

Remove packages and its dependencies that are not required by other packages

yay -Rs <packagename>

+++

Remove packages and its dependencies that are not required by other packages + remove config files

yay -Rns <packagename>

+++

Update all packages from AUR repo in system

yay -Sua

+++

List installed AUR packages

yay -Qm

# pacman Mirrorlist

pacman pulls packages from mirror sites listed in etc/pacman.d/mirrorlist. This list of mirrors may need to be updated from time to time so we have a list mirrors that have the fastest download times (for example).

# Reflector

We can use reflector to fetch the latest mirror list and overwrite etc/pacman.d/mirrorlist. See the archwiki (opens new window) for full configuration options.

# pacman Cache Buildup

pacman cache keeps all previously installed packages and is not cleaned up automatically.

We can use paccache (comes with pacman-contrib package) to clean up cache. See archwiki (opens new window).

Run the following to clean up cache. The command keeps the most recent 3 versions of packages by default.

paccache -r

# Setting up paccache Timer

paccache comes with a systemd timer (paccache.timer). We can set it up to run automatically at an interval by enabling and starting the systemd timer unit. See archwiki (opens new window).

By default, paccache.timer is set to run on a weekly basis. This may be too often and we can change it to run monthly instead.

# Editing paccache.timer to Run Monthly

Edit paccache.timer with "drop-in files" following this archwiki (opens new window).

The override file should look like this:

[Timer]
OnCalendar=
OnCalendar=monthly

# Downgrading Packages

# Using pacman Cache

If a package was installed at an earlier stage, and the pacman cache was not cleaned, install an earlier version from /var/cache/pacman/pkg/.

This process will remove the current package and install the older version. Dependency changes will be handled, but pacman will not handle version conflicts. If a library or other package needs to be downgraded with the packages, please be aware that you will have to downgrade this package yourself as well.

pacman -U file:///var/cache/pacman/pkg/package-old_version.pkg.tar.type

Note that type will be xz for older package builds, and zst for newer ones.

archwiki (opens new window)

# Skip Package from being Upgraded

We can skip upgrades for specific packages during pacman -Syu by including these packages in the IgnorePkg list.

Go to /etc/pacman.conf, and can find the IgnorePkg list under the [options] section. The list accepts a space separated list.

archwiki (opens new window)

# Troubleshooting

# "Invalid or corrupted package (PGP signature)" Error Message

You might get this error message if you haven't updated packages in a long time. To solve this, simply reinstall archlinux-keyring by doing:

pacman -S archlinux-keyring

The command will update new keys and disable the revoked keys in your Arch Linux system. You should be able to update packages after this.

# More Info

Description on how packages are handled on Arch here (opens new window)