Arch Linux is a popular Linux distribution that is revered for its simplicity and rolling release. It does away with many of the apps that ship with other distributions, and you are free to install the apps you want and need. However, you will have to be comfortable with its package manager – Pacman.
The Pacman package manager provides users with a simple way of managing packages. Packages can be managed from either official repositories or from a user’s own builds with Pacman. Follow this guide to master Pacman for Arch Linux.
Updating the System
To update the system and all installed software, use the command:
To force a full refresh of the package database and update the system:
Searching for Packages
If you want to install a package but can’t quite remember the package name, then you can do a keyword search directly from the terminal.
For example, if you wanted to install gimp, you could do a search to see what the available packages are called.
To search for installed packages:
You can use the command below to install single or multiple packages:
However, it is better to update the system first before installing any packages. Use the following command to update and install software:
Installing Packages from Third-Party Sources
You won’t always be installing packages from remote repositories. To install packages from a local directory, use the following:
If you want to install a package from an unofficial repository, you can use the following command:
Listing Installed Packages
If you just want to see all the installed packages in your system, use the command:
There are instances when you want to download a package but not install it. Use this command:
Package removal goes hand-in-hand with package installation. To remove a package and leave its dependencies behind, use the following command:
If you want to remove a package and its dependencies that aren’t used by other packages, then run this command:
To check for orphan files:
You can combine it with the following command to remove unused packages/orphans and their configuration files:
Remove Everything except the base system
This is kind of a way to start from scratch. If there is a need to “factory-reset” your system, the following two steps allow you to do so easily.
First, we need to make all installed packages become a “dependency:”
Next, we need to change the installation reason for essential packages (base system) to “as explicitly,” so they don’t get treated as orphans and get removed:
Lastly, we will remove all the “orphaned” files:
Clearing Package Cache
Pacman doesn’t automatically clear out old or uninstalled versions of packages automatically. This allows for easy downgrades and easy reinstallation from the cache folder. However, as the cache grows inside, it may get out of hand. We have a dedicated article on clearing Pacman’s cache, but here is the gist:
This command clears out all of the cached versions of installed and uninstalled packages except for the three most recent ones.
To just clear out cached packages that aren’t currently installed, run the following:
If you want to completely clear your cache, run the command below. This will leave your cache folder completely empty.
Please note that this is by no means an exhaustive list. The possibilities are endless with Pacman, and you will need to spend some time getting familiar with other commands not mentioned here. However, Arch Linux’s documentation is excellent and is a good point of reference. With that being said, we have given you a solid base here. Learn these commands, and you will be quite competent with Arch Linux.