Appearance
Package Management on Arch
Common pacman
Commands
Install packages from Arch standard repository
sh
pacman -S <packagename>
+++
Remove packages and its dependencies that are not required by other packages
sh
pacman -Rs <packagename>
+++
List installed packages (including AUR)
sh
pacman -Qs
+++
Search installed packages (including AUR)
sh
pacman -Qs <regex>
+++
List installed packages only found in sync db(s)
sh
pacman -Qn
+++
List installed packages not found in sync db(s) (e.g. AUR only)
sh
pacman -Qm
+++
Get detailed info of a package (e.g. installation date)
sh
pacman -Qi <packagename>
+++
Update all packages from standard repo in system
sh
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
sh
yay -S <packagename>
+++
Remove packages and its dependencies that are not required by other packages
sh
yay -Rs <packagename>
+++
Remove packages and its dependencies that are not required by other packages + remove config files
sh
yay -Rns <packagename>
+++
Update all packages from AUR repo in system
sh
yay -Sua
+++
List installed AUR packages
yay -Qm
+++
Clean yay
cache from ~/.cache/yay/
(AUR only)
sh
yay -Sca
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 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.
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.
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.
The override file should look like this:
[Timer]
OnCalendar=
OnCalendar=monthly
- See here to understand why we need to set
OnCalendar=
first. - See systemd.time man to the possible configurations for
OnCalendar
.
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.
sh
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.
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.
Upgrading yay
You will need to upgrade yay
manually if it was installed by building from source following this guide.
First, remove yay
with pacman
(like you would any other package):
pacman -Rs yay
Re-install yay
following the same guide above.
Inspect Dependency Tree of a Package
Use pactree
to view dependencies of a package. Example usage to view dependencies of bash
:
~$ pactree bash
bash
├─readline
│ ├─glibc
│ │ ├─linux-api-headers>=4.10
│ │ ├─tzdata
│ │ └─filesystem
│ │ └─iana-etc
│ ├─ncurses
│ │ ├─glibc
│ │ └─gcc-libs
│ │ └─glibc>=2.27
│ └─ncurses provides libncursesw.so=6-64
├─readline provides libreadline.so=8-64
├─glibc
└─ncurses
The reverse is also possible: you can view the dependents of a package with the -r
(reverse) flag:
~$ pactree -r snappy
snappy
└─ffmpeg
└─firefox
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.
yay
Tries to Install Bloated chromium-mirror
When upgrading AUR packages with yay
, it may try to pull ~40GB worth of files from .../electron25/chromium-mirror
if some of your packages require electron25
as a dependency.
You can get around this by first installing electron25-bin
(see here) to satisfy the dependency, then upgrade your AUR packages.
More Info
Description on how packages are handled on Arch here