« Back to Linux cheat sheets

pacman cheat sheet

This article has last been updated at .

This cheat sheet is focused on the pacman command, the package manager for systems like Arch Linux.

Basic usage

Pacman uses mostly command options and their action might not always be clear, especially when using the shortened aliases. So here is a basic list with the options in long and short format, followed by the intended action.

CommandShort versionIntended action
--query --deps --unrequired-QdtFind all packages that are installed as dependency but no longer required
--remove PACKAGE-RRemove specified package
--remove --recursive PACKAGE-RsRemove package and dependencies, except those linked to other packages or manually installed
--sync PACKAGE-SInstall a package
--sync --search REGEX-SsSearch for a package
--sync --refresh-SyRefresh the package database information

Search a package

If you know the name or a part of the name, then we can combine --sync with --search to search with a regular expression.

# pacman -Ss lynis
extra/lynis 3.1.2-1
    Security and system auditing tool to harden Unix/Linux systems

Example using a regular expression.

pacman -Ss "lyn*"

Installation, update, upgrade, and removal of packages

Install new package

Install a single package.

pacman -S lynis

Update the database information

pacman -Sy

Requires root permissions

Upgrading packages

To update and upgrade the full system.

pacman -Syu

Remove a package

Remove a single package

pacman -R lynis

Remove a package including its dependencies, except those dependencies that are linked to another installed package or were manually installed by the user.

pacman -Rs lynis

Remove a package and also its dependencies.

pacman -Rsc lynis

File information

Synchronize the package database and search for files with a particular name.

# pacman -Fy lynis
:: Synchronizing package databases...
 core       1110,9 KiB  7,38 MiB/s 00:00 [-----------------------] 100%
 extra        44,3 MiB  84,1 MiB/s 00:01 [-----------------------] 100%
 multilib    223,7 KiB  1912 KiB/s 00:00 [-----------------------] 100%
extra/lynis 3.1.2-1
    usr/bin/lynis
    usr/share/bash-completion/completions/lynis

To search with a regular expression, provide also the --regex option.

sudo pacman -Fxy lyni
:: Synchronizing package databases...
 endeavouros is up to date
 core is up to date
 extra is up to date
 multilib is up to date
extra/lynis 3.1.2-1
    usr/bin/lynis
    usr/lib/systemd/system/lynis.service
    usr/lib/systemd/system/lynis.timer
    usr/share/bash-completion/completions/lynis
    usr/share/man/man8/lynis.8.gz
extra/tela-circle-icon-theme-black 2024_11_15-2
    usr/share/icons/Tela-circle-black/scalable/apps/dev.lynith.Speedtest.svg
extra/tela-circle-icon-theme-blue 2024_11_15-2
    usr/share/icons/Tela-circle-blue/scalable/apps/dev.lynith.Speedtest.svg
extra/tela-circle-icon-theme-brown 2024_11_15-2
    usr/share/icons/Tela-circle-brown/scalable/apps/dev.lynith.Speedtest.svg
extra/tela-circle-icon-theme-dracula 2024_11_15-2
    usr/share/icons/Tela-circle-dracula/scalable/apps/dev.lynith.Speedtest.svg

Maintenance

Packages that are no longer required

Search for any dependencies that are no longer required.

pacman -Qdt

Relevant articles using pacman command

The following articles include an example on how to use pacman and might be worth further exploring.

Liked this cheat sheet? There are more!

Related and similar commands

Linux has a lot of tools and commands available and sometimes you just need that little other tool. Here is a list of commands that are similar or related to pacman:

Related and similar commands to pacman
CommandCategorySummary
aptpackage managementPackage manager
apt-filepackage managementSearch tool for files belonging to packages

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

Mastodon icon

Related articles

Like to learn more? Here is a list of articles within the same category or having similar tags.