Arch Linux

How to Use Pacman on Arch Linux

Pacman, which stands for “package manager”, is the standard command-line tool to administer the software packages under Arch Linux. It manages the system’s package database and is utilized to install, update, and uninstall the packages. One of the greatest package managers for Linux, Pacman is renowned for its simplicity, speed, and versatility. In this guide, you will see how we can use it for different purposes with the help of some illustrations.

Update and Upgrade Using Pacman

Let’s get started with some commands of Arch Linux to demonstrate the use of the pacman utility. The very first utilization of a pacman is to use it for synchronizing the local package database with the remote package repositories. The following command ensures that the packages that are installed on the system are up-to-date and have the latest security and bug fixes. The “-S” flag is used to tell pacman to perform a synchronization operation. The “y” flag is used to tell pacman to assume yes to any prompts or confirmations during the synchronization operation.

[omar@omar ~]$ sudo pacman -Sy

The same Pacman command can be modified with the use of the extra “y” flag which is used again to confirm that the user wants to proceed with the update. This is a safety measure to prevent accidental updates.

[omar@omar ~]$ sudo pacman -Syy

[sudo] password for omar:

After synchronizing the packages with the “-S” flag and refreshing the package lists with the “y” flag, you can use the “u” flag to perform a full system upgrade. This includes updates to the system’s packages as well as upgrades to any packages that have new available versions. The output of the command shows that there are no new updates available for these packages at the moment.

[omar@omar ~]$ sudo pacman -Syu

By arranging the flags in one instruction, we can achieve whatever goal we want. Now, the “y” after the “-S” flag is used to refresh the package lists. The third flag, “y”, is used again to confirm that the user wants to proceed with the update. The fourth flag, “u”, tells pacman to perform a full system upgrade. When the command is executed, it starts by synchronizing the package databases and ends with a full system upgrade.

[omar@omar ~]$ sudo pacman -Syyu

The following command demonstrates the use of the “-u” option twice. It is the option to perform a system upgrade and downgrade whenever possible. The output shows that all installed packages are already the latest version and there are no available updates.

[omar@omar ~]$ sudo pacman -Syuu

If you want to combine all the purposes of the different flags that we previously used, you can combine all the flags in one instruction like what we did in the following illustration. The “-yy” is the option to refresh all packages, and the “-u” is the option to perform a system upgrade. The additional -y option makes sure that pacman downloads the entire package list again and updates the package list cache. This can help if you are facing issues with the package list being out of date.

[omar@omar ~]$ sudo pacman -Syyuu

Download the Packages Using Pacman

The pacman command can be useful to download any package on Arch Linux without being installed. For this, we need to use the “-Sw” flag in the instruction. The following command is the illustration of downloading a gimp package in an Arch Linux system without installing it. The command downloads the gimp package and its dependencies, but it does not install them.

[omar@omar ~]$ sudo pacman -Sw gimp

Install the Packages Using Pacman

The pacman command is very useful when you want to download or install some package on your ArchLinux machine. Similarly, you need to use the “-S” option to install a package along with the name of the package. The following instruction shows that the package name that is specified after the option is “firefox”. After resolving the dependencies, the command prompts the user to confirm if they want to proceed with the installation. If the user inputs “y”, the command proceeds with the installation. In this case, the output shows the progress of the installation of the “firefox” package. The command installs Firefox and any dependencies.

[omar@omar ~]$ sudo pacman -S firefox

The previous illustration shows how you can install a single package using the pacman instruction. Now, we will see how we can install multiple packages at once. The following command shows the package names that are specified after the python-pip and python-py options, separated by a comma and enclosed in curly braces {}. Once the download is done, the command then proceeds with the installation of the remaining packages and shows the progress of the installation.

[omar@omar ~]$ sudo pacman -S python-{pip,py}

Remove the Packages Using Pacman

Just like we have to perform the download and installation through the pacman instruction, we can also use the pacman instruction to remove an installed package from our system. For this, we need to use the “-R” option along with the “inkspace” package name in the pacman instruction. Inkscape and all other packages that are installed as “inkscape’s” dependencies but are no longer required by any other package are deleted from the system whenever this command is performed.

[omar@omar ~]$ sudo pacman -R inkscape

List the Installed Packages Using Pacman

The “pacman” command can be executed to list all the installed packages of a system all at once. For this, we need to utilize the “-Q” option to query the package database for installed packages. When this command is executed, it displays a list of all packages that are currently installed on the system. The package name, version, and repository that it was installed from are displayed for each package.

[omar@omar ~]$ pacman -Q

The use of the “-s” flag with the “Q” flag is useful to search for an installed package by name within the Arch Linux system. For instance, the following command demonstrates that we are using the “-Qs” combined to search for the installed “firm” package. When this command is executed, it searches the locally installed packages for any package that matches the name, “firm”. The output shows the name, version, and description of any package that matches the search term, “firm”.

[omar@omar ~]$ sudo pacman -Qs firm

Conclusion

After going through this guide, you will be able to use the pacman instruction in your Arch Linux without hesitating. This article covers the use of pacman instruction using some of its useful flags like –S, -y, -u, -Q, -Qs, -Sw, and –R. The pacman command covers the updates, upgrades, download, installation, removal, and search on particular packages.

About the author

Omar Farooq

Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.