Want to install packages on Arch Linux but don’t know how? Many people run into this issue when they first move to Arch. However, you can easily manage packages on your Arch-based system using the Pacman package manager.
Pacman stands for Package Manager, combines a simple binary package format with an easy-to-use build system.
It is the default command-line package management tool in Arch Linux and its derivatives. You can easily install, remove, update, and upgrade packages and all required dependencies with it.
This guide applies to Arch Linux and all the other Arch-based Linux distros such as Manjaro, EndeavourOS, Garuda Linux, etc., using Pacman as the package manager.
So, let’s see how to use Pacman to install, remove, update, and query packages in Arch Linux with simple examples.
Table of Contents
- Refresh Package Lists
- Searching for Package
- Getting Information About Package
- Installing a Package with Pacman
- Installing a Local Package
- Update/Upgrade a Package
- Remove a Package with Pacman
- Remove Orphaned (Unused) Packages
- Searching for Already Installed Packages
- Find All Files Owned by a Package
- Find the Package Owner of the File
- Download a Package
- Clean-Up Package Cache
Refresh Package Lists
Like in all Linux operating systems, we must update the package lists before installing any packages or updating the system.
sudo pacman -Sy
Searching for Package
To search for a specific package, for example,
vlc, from a sync database (remote server), run:
sudo pacman -Ss vlc
Getting Information About Package
To display the detailed information of the given package from the sync database, for example for
pacman -Si nginx
Installing a Package with Pacman
Installing a package with Pacman is easy. Just run the following command:
sudo pacman -S vlc
As a result, this process will automatically identify all the necessary dependencies and take care of them.
Installing a Local Package
Pacman stores all downloaded packages in
In case you want to install the locally downloaded package, for example,
vlc, located in /var/cache/pacman/pkg/ directory, go to the folder where the package is located and enter the following command:
cd /var/cache/pacman/pkg/ sudo pacman -U vlc-3.0.11-2-x86_64.pkg.tar.zst
Update/Upgrade a Package
To update a single package, for example,
sudo pacman -S rsync
To update all packages in your system, just run:
sudo pacman -Syu
Sometimes you want to upgrade the packages, but you want it to stay at an older version (because you know the newer version has removed a feature or is broken).
So, if the
vlc package was causing the problem, you could use the following command for this:
sudo pacman -Syu --ignore=vlc
Remove a Package with Pacman
To remove a package with all its dependencies, run the following command:
sudo pacman -Rs vlc
This command will altogether remove the
vlc package and all dependencies. While removing packages, Pacman will keep the critical configuration files with the extension
In addition, if you no longer want them and want to free up the hard drive, you can remove the package along with all its configuration files with the command:
sudo pacman -Rns vlc
Remove Orphaned (Unused) Packages
As you might know, there will still be some orphaned (unused) packages in your Arch Linux after removing a package. These orphaned packages are not required anymore, so we can get rid of them to free up some space.
To remove these packages, run:
sudo pacman -Rns $(pacman -Qdtq)
If no orphans were found, the output is:
Searching for Already Installed Packages
Sometimes you want to check for a specific package if it is installed locally. In this case, you can do it using the command below:
pacman -Qs vlc
You can view a list of all the packages installed on your system using the following command:
Find All Files Owned by a Package
You can find all the files that are installed by a specific package using the following command:
pacman -Ql vlc
This returns the package name and the path to files that it owns.
Find the Package Owner of the File
If you want to check the location of the binary executable file owned by a package, use the
pacman -Qo /usr/bin/vlc
Download a Package
Sometimes, you might want to download a package and keep it in your cache without installing it. For example, you might plan to use the downloaded packages. To do so, run:
pacman -Sw vlc
The above command will only download the
vlc package and keep it in the cache folder. Pacman stores all downloaded packages in
Clean-Up Package Cache
All packages that we downloaded during the installation will be stored in the cache directory, i.e.,
/var/cache/pacman/pkg/. If you don’t remove them periodically, it will slowly eat up your hard drive space, and sooner or later, you could end up with low disk space.
So it is good to remove the cache periodically. To remove all the cached packages that are not currently installed and the unused sync database, execute:
sudo pacman -Sc
In addition, if you want to remove all files from the cache, use the clean
c switch twice. Of course, this is the most aggressive approach and will leave nothing in the cache folder:
sudo pacman -Scc
Arch Linux is one of the most reputed and famous Linux distributions. This guide has covered most of the commands you need to know when using Pacman.
Hopefully, it was helpful in your journey with Arch-based distros.
You can find detailed documentation about the Pacman package manager in the official Arch Linux Wiki.