Arch Linux

How to Use Pacman on Arch Linux

Arch Linux is one of the most reputed and popular Linux distros out there. It’s a challenging one. That’s why not every Linux user is fond of it. Among all the distinguishable features, the “pacman” package manager is a major one. The goal is to offer a simple way of using the build system and manage packages, whether it’s grabbed from the official repositories or user’s own builds.

With pacman, unlike APT or YUM, it has its own structure of commands. It’s a simple guide to all the must-know and some interesting additional commands for “pacman”.

The following guide applies to Arch Linux and all the other Arch-based Linux distros using pacman as the package manager. Sometimes, people prefer using Arch-based distros instead of the original one because of the complex installation mechanism. But the fact is, it’s quite easy! It’s just a matter of a little more focus and patience. Learn how to install Arch Linux.

Pacman command

There are tons of ways you can utilize pacman. Of course, you don’t need them on a regular basis. The following guide is a short collection of all the must-know and interesting methods of using pacman. The entire “pacman” guide is available at the official Arch Linux Wiki.

Update the database

For any package manager to work properly, it has to be in sync with the master servers. The same goes for pacman. To update the package database of pacman, run the following command:

sudo pacman -Sy

It’s possible to force pacman to update the package database. This will recreate the package database. Use the following command:

sudo pacman -Syy

Upgrade software

You can tell pacman to perform a full upgrade of the system. This will upgrade all the upgradable packages to the latest version.

sudo pacman -Syu

You can combine forced package database update with the upgrade command. This will look something like this:

sudo pacman -Syyu

The next command will tell pacman to upgrade/downgrade the installed packages to the version that’s available on the master servers.

For example, if you have package “xyz-1.5” installed in your system but “xyz-1.4.9” is the latest version on the master server, pacman will downgrade to “xyz-1.4.9”.

sudo pacman -Syuu

Both can also be combined to perform a similar action.

sudo pacman -Syyuu

Installing package(s)

Installing a package with pacman is really easy. Just run the following command:

sudo pacman -S <package_name_1> <package_name_2>

This process will automatically identify all the necessary dependencies and take care of it.

In cases, packages come up with similar patterns. Instead of typing the same name over and over, use brackets as a shortcut. For example, for installing Python packages like pip, py, pytest, and pytest-runner, run the following command:

sudo pacman -S python-{pip,py,pytest,pytest-runner}

Note: Between the comma and the next package name, there MUST not be any space. Otherwise, the command won’t work.

sudo pacman -S python-{pip, py, pytest, pytest-runner}

In cases, you may just want to download the package. Pacman can be used to perform the action for you. Just use the “-Sw” flag.

sudo pacman -Sw <package_name>

Pacman will only notify you about the download size as the package is only going to be downloaded, no installed.

Pacman will download the package as <package_name>.tar.xz file and store it at “/var/cache/pacman/pkg” directory. In fact, all the Arch Linux packages are available in the .TAR.XZ format. Don’t worry; pacman can directly install a .TAR.XZ file provided that it’s a legit Arch Linux package file.

sudo pacman -U <package_name>.tar.xz

If you didn’t know, all the packages you download with pacman will always be there. Check out what packages are there.

ls /var/cache/pacman/pkg

Need to find out specific packages? Use “grep” to search for a specific package.

ls /var/cache/pacman/pkg | grep <package_name>

If you ever need to install/upgrade/downgrade any package, you know where to find the package.


If you’re confused with the package name, ask pacman to search it for you!

pacman -Ss <search_term>

This method doesn’t have any color highlighting. Bummer! Don’t worry; pacman already knows how to colorize the output but the function is disabled by default. Want to see the colorful output? Edit the “pacman.conf” and uncomment the “Color” option.

sudo nano /etc/pacman.conf

Don’t forget to check out the result!

Besides the basic search mechanism, there are different ways of searching for a package. The basic one is quite useful, but sometimes, knowing other ways of doing the same thing can offer better benefits.

I love using “grep” for that purpose. Use pacman to list all the available packages and then, pipeline the output to “grep” to show all the necessary packages.

pacman -Ssq | grep python

Did you notice the “-Ssq” flag? It tells pacman to print ALL the available packages, one at a line. I pipelined it to grep to show only the python3 packages. Sure, you don’t get the short package description.

There’s another built-in tool for doing all the searching for you: pacsearch. It offers a better view of the output with nice coloring and formatting. It should be available in your system. However, for some reason, if your system doesn’t have it installed, install it right away! It’s a part of the “pacman-contrib” package. Tell pacman to do the installation for you.

sudo pacman -S pacman-contrib

Now, let pacsearch to do the previous action.

pacsearch python

Package information

The following command will list all the installed packages on your system.

pacman -Q

It’s always going to be pretty long and confusing. If you’re looking for any specific package, use “grep”.

pacman -Q | grep linux

If you’re in need of detailed information about a certain package, use “-Qi” flag with pacman.

pacman -Qi <package_name>

If you don’t pass any package name in the argument, it will show the information of all the packages in the pacman package database. Using “grep”, it’s possible to modify the output to show your desired information only.

pacman -Qi | grep -e ‘Name’ -e ‘Installed Size’

This command flag “-Q” will only show the installed package information. Need to check out the latest information about a package? Use “-Si” flag instead.

pacman -Si <package_name>

pacman -Si | grep -e ‘Name’ -e ‘Download Size’ -e ‘Installed Size’


With pacman, uninstalling a package is more secure. Just run the following command:

sudo pacman -R <package_name>

Note: It will ALWAYS ensure that it doesn’t break the dependencies. If you’re ever trying to uninstall a dependency, it’ll block the uninstallation process.

If you’re willing to uninstall a package along with all the dependencies (no other packages depend on those dependencies), then use the following command structure:

sudo pacman -Rs <package_name>

It’s possible to force pacman to uninstall a package, no matter whether it breaks other dependencies or not. It’s an extremely dangerous way of uninstalling a package and strongly NOT RECOMMENDED if you’re unsure of what you’re doing.

sudo pacman -Rdd <package_name>

Final thoughts

Pacman is a powerful package manager for Arch Linux. No package gets past it. Even if you install packages from other sources like the AUR repository, it must go through pacman to complete the installation. As one of the most important components of the Arch ecosystem, it’s no wonder you must confront the console window and ask pacman to perform certain tasks. Hopefully, this short guide was helpful in your journey with Arch Linux.

About the author

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.