sodcalculator

10 Tech How-To

Verify Arch Linux Packages Before Installing

Guide 10-58244 · Updated · Step by step

Installing software on Arch Linux is fast and easy, but the official repositories and the AUR contain packages from many different maintainers. Verifying a package before you install it protects you from corrupted downloads, tampered files, and malicious code. This guide walks you through the practical steps to check a package’s integrity and authenticity, whether it comes from the official repos or the Arch User Repository.

What You’ll Need

  • A working Arch Linux installation with pacman.
  • An internet connection.
  • For AUR packages: git and a helper like yay or paru (optional, but recommended).
  • Basic familiarity with the terminal.

Step-by-Step

Verifying Official Repository Packages

  1. Update your package database. Run sudo pacman -Sy to sync the repository indexes. This ensures you are working with the latest package information.
  2. Check the package signature. Pacman automatically verifies PGP signatures of all packages from official repositories during download and installation. To manually verify a package file you already have, use gpg --verify package.pkg.tar.zst.sig package.pkg.tar.zst. The signature file (with .sig extension) is usually downloaded alongside the package.
  3. Verify the package checksum. Pacman also checks SHA-256 checksums for every package. To see the expected checksum for a package in the repos, run pacman -Si package-name and look for the “MD5 Sum” and “SHA-256 Sum” fields. Then, after downloading the package with pacman -Sw package-name, compare the actual checksum using sha256sum /var/cache/pacman/pkg/package-name.pkg.tar.zst. If they match, the package is intact.
  4. Inspect the package contents. Use pacman -Qlp package-name to list files that would be installed. This lets you see exactly what the package will place on your system. Look for anything suspicious, like files in unusual locations or scripts that run automatically.

Verifying AUR Packages

  1. Read the PKGBUILD. The PKGBUILD is the build script that defines how the package is made. For any AUR package, always review it before building. Download the package source with git clone https://aur.archlinux.org/package-name.git and then open the PKGBUILD in a text editor: cd package-name && nano PKGBUILD.
  2. Check the source URLs. Look at the source=() array in the PKGBUILD. The URLs should point to the official upstream project (for example, a GitHub release page or the project’s own site). If the URL looks suspicious or is a shortened link, do not proceed.
  3. Verify upstream checksums. The PKGBUILD should contain a sha256sums=() array with the expected checksums of the downloaded files. After downloading the source files (run makepkg -o to fetch them), verify them with sha256sum and compare against the values in the PKGBUILD. If they differ, the source may have been tampered with.
  4. Check the PGP signatures (if provided). Many upstream projects sign their release files. If the PKGBUILD includes a validpgpkeys=() array, it lists the fingerprints of trusted keys. When you run makepkg, it will attempt to verify these signatures. If you see a warning about an untrusted key, investigate before continuing.
  5. Use a helper with built-in checks. Tools like yay and paru automatically show you the PKGBUILD before building and ask for confirmation. They also verify checksums and signatures by default. If you use one, you still need to review the PKGBUILD yourself—the helper only makes the process easier, not safer.

Common Mistakes

  • Skipping the PKGBUILD review. The most common mistake is blindly trusting AUR packages. Even popular AUR packages can have malicious updates, so always read the PKGBUILD.
  • Ignoring PGP warnings. If pacman or makepkg warns about a missing or invalid signature, do not ignore it. It could mean the package was tampered with.
  • Using pacman -Sy before installing. This partial upgrade can cause dependency issues. Instead, use pacman -Syu to fully update your system.
  • Assuming all AUR packages are safe. The AUR is user-maintained; there is no official review process. Even well-known packages can have occasional bad updates.
  • Not checking the source URL. A PKGBUILD that downloads from a random file-sharing site instead of the official project is a red flag.

Tips

  • Use pacman -Qi package-name after installation to see the install date and version. This helps you track updates.
  • For AUR packages, check the comments on the AUR page. Other users often report issues or suspicious behavior there.
  • Consider using a sandbox or virtual machine to test AUR packages before installing them on your main system.
  • Keep your system updated regularly with sudo pacman -Syu to ensure you have the latest security patches.
  • If you are building an AUR package, run makepkg -s to install missing dependencies automatically, but review them too.

Troubleshooting

  • “invalid or corrupted package (PGP signature)” – This means the package signature does not match. First, update the keyring with sudo pacman -Sy archlinux-keyring and try again. If it persists, the package may be corrupted or tampered with; do not force installation.
  • “failed to verify signature” – For AUR packages, this often means the upstream key is not in your keyring. Import the key with gpg --recv-keys <key-id> after verifying the fingerprint from the official project site.
  • Checksum mismatch – If the checksum in the PKGBUILD does not match the downloaded file, the source may have changed upstream. Check the AUR comments; sometimes the maintainer needs to update the checksum. If the source URL looks legitimate, you can update the PKGBUILD checksum, but only after verifying the file is authentic.
  • makepkg fails with “source not found” – This usually means the source URL is incorrect or the file name in the source=() array does not match. Double-check the URL and the file name.
  • Pacman says “package is not signed” – This can happen if the package was built locally or from an unofficial repo. For official repos, ensure your pacman.conf has SigLevel = Required DatabaseOptional (or stricter).

Frequently Asked Questions

Do I need to verify official repository packages every time?

No. Pacman does it automatically. The steps above are for when you want to manually double-check a package, or when you are installing a package that is not from the official repos.

What is the difference between a checksum and a PGP signature?

A checksum (like SHA-256) verifies that the file has not been corrupted or altered accidentally. A PGP signature verifies that the file was actually created by the expected maintainer and not tampered with by a third party.

Is the AUR safe to use?

The AUR is a community repository. Most packages are safe, but there is no guarantee. Always review the PKGBUILD and check the comments. Use a helper that shows you the build script before installing.

How do I know if a PKGBUILD is malicious?

Look for anything that runs arbitrary code, like curl or wget with a URL that is not the official source, or scripts that modify system files outside of the package directory. If anything looks odd, search the web for the package name and “malicious” to see if others have reported it.

Can I trust packages from the official Arch repositories?

Yes, the official repositories are maintained by trusted packagers and all packages are signed. However, you should still keep your system updated to receive security fixes.

What is the best way to verify a package after downloading it?

Use pacman -Sw to download the package, then verify the signature with gpg --verify and the checksum with sha256sum. Compare both against the values shown by pacman -Si.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →