The Basics of Pacman Package Manager

The Basics of Pacman Package Manager

I recently switched to Arco Linux, a distribution based on Arch Linux, and one of the first things I had to learn was how to use its package manager, called Pacman. In this article, I will provide a summary of the basic operations of Pacman and explain them to you step by step.

Refreshing Cache

Like all other package managers, Pacman synchronizes packages with the online repositories to which you subscribe. An online repository is something that has an updated list of all the packages available for download, therefore it is a good practice to sync with this cache and have a copy of that on our system.

To do this type the following command:

sudo pacman -Syy

Here, the option S is for sync, y is for proceeding with the sync and the second y is for force refresh even if the package is there on our local cache.

Installing Package

To install any package you need to type the following command:

sudo pacman -S <package>

Here <package> should be replaced with the name of your desired package. Again the option S refers to sync.

You can install multiple packages in the single command as:

sudo pacman -S <package1> <package2> <package3>

Removing Package

To remove a particular package the syntax is as below:

sudo pacman -R <package>

This will remove the package along with all its dependencies. Pacman will take care of this for you by default. Here the option R refers to remove.

Finding Packages

What if you need to install a package but you don't know the exact name by which it is identified in the repository? Well in that case you have two options:

  1. Go to https://archlinux.org/packages/ and search for the keyword or description of the package

  2. Search with Pacman

Here the first step is the easy one therefore I will show you the second step. To find a package with Pacman type the following command:

sudo pacman -Ss <package>

In case there appeared 100s of packages with the similar name and you want to filter out a specific one then you can make use of the grep command as below:

sudo pacman -Ss <package> | grep <specific keyword>

Removing Orphan Packages

The packages which are no longer required by any other package are orphans. It is not necessary to remove these packages but it will take more time and data to upgrade your system. So to remove these packages follow these steps:

#step 1
pacman -Qdt

#step 2
sudo pacman -R <package>

In step 1, we do not use sudo because we are not going to do any changes. What this command does is, it just lists down all the orphan packages in our system.

The option Q is to query, d is to skip the dependency checks and the option t is to filter out the result with orphan packages.

Next step 2 is as usual to remove those listed packages.

Upgrading System

To upgrade your system with Pacman the command is easy, you just need to type the following command:

sudo pacman -Syu

Again S indicated sync, y is for proceeding and u is to upgrade.

Final Words

In conclusion, Pacman is a powerful and efficient package manager for Arch-based Linux distributions like Arco Linux. It offers a wide range of commands for managing packages, resolving dependencies, and maintaining the system.

By following the steps outlined in this article, you should now have a good understanding of how to use Pacman to manage your packages on your system. Whether you are a beginner or an experienced Linux user, Pacman is a valuable tool to have in your toolkit.

And as always, Keep Reading, Keep Exploring and Keep Learning.