Pacman Package Manager in Linux [How to Use It]

Pacman package manager is used in Arch-Linux distribution. In this article, I have shown what Pacman package manager is, its uses, and the management of software with it. I hope it will help the user to learn more about the package manager.

Table of Contents Expand

What Is the Pacman Package Manager?

Pacman is a package manager that is used in the Arch-Linux distribution and its derivatives such as Manjaro, KaOS, and EndeavourOS. It facilitates the management of the system by installing, removing, and upgrading the packages. Like apt, yum, and dnf package managers, it is a powerful tool for managing software packages within Arch-based systems.

The Key Components of Pacman

The users who use the package manager for the first time should know about the key components of Pacman. Here I have shown the modules:

  • Usage: Used in Arch Linux and its derivatives Manjaro, KaOS, and Frugalware.
  • File extension: The file extension for the Pacman package manager is .pkg.tar.xz.
  • Key Features: Lightweight, fast, High-speed packaging, two types of repository, Automatically upgrade package.
  • Dependency Handling: Dependency resolution, install the specific program with all other needed dependencies.

Why Use Pacman Package Manager

Pacman is the package manager that is mainly used for the Arch-Linux distribution. It has some advantages that make it more attractive:

  • Package availability: Packages are usually more up-to-date.
  • Speed: High-speed packaging which is convenient for large files.
  • Customization: Once a package is installed pacman provides the facilities to the user to customize it according to their preference.

Package Management With Pacman

Managing packages means installing, removing, searching, handling a repository, and showing information about a package. Below I will illustrate the management of packages with pacman.

Install Packages With Pacman

The common function of any package manager is to install a package. With pacman, you can install single packages, multiple packages, and local packages. Here you can see some of the installation commands below.

How to Install Single Package

To install a single Pacman package you have to use the install option. Here I have used the gnome package You can use any package according to your liking. To practice, you can copy this command:

sudo pacman -S gnome
EXPLANATION
  • sudo: Permits administrative privileges.
  • pacman: Provide a command line interface for the package management system.
  • -S: Command install the following package.
  • gnome: The group of packages that I want to install.

Install a group of package with pacman

You can see the group of packages inside the gnome from the image. To proceed to the next step, you have to press ENTER when it will ask for selection.

Press enter to continue the installation

To the confirmation of installation, the user must press Y and ENTER.

Confirmation for installation

How to Install Multiple Packages Using Pacman

You can install multiple packages with Pacman at a time. To install multiple packages with pacman you can copy the following command:

sudo pacman -S vlc cmatrix python
EXPLANATION
  • vlc, cmatrix, python: The packages that I want to install.

Install multiple packages with pacman

If one installed a package before and again tries to install that package then it reinstalls the newer version of that package.

How to Install a Package Locally

To install a local package you can copy the following command:

sudo pacman -U /home/oishi/Downloads/zoom_x86_64.pkg.tar.xz
EXPLANATION
  • -U: Option to install a package locally.
  • /home/oishi/Downloads/zoom_x86_64.pkg.tar.xz: Path where the downloaded packages are stored.

Install a package locally with pacman

The local file should be downloaded to your system.

How to See the Dependency Tree

If you want to see the dependency tree of a specific package then you can copy the following command:

sudo pactree cmatrix
EXPLANATION
  • pactree: Option to display the dependency tree of the following package.

Showing dependency tree with pacman

Remove Packages With Pacman

Sometimes you install a package but later you do not need the file anymore. So you can uninstall or remove it with the remove option. In this section, I have shown how to remove a single package and unnecessary packages.

How to Remove a Single Package Using Pacman

To remove a package with Pacman you can use the following command:

sudo pacman -R cmatrix
EXPLANATION
  • -R: Option to remove the desired package from the repository.
  • cmatrix: The package that I want to remove.

Remove a package with pacman

To confirm the removal of the package, you must press Y and then Enter.

How to Remove a Package With Its Dependencies

When you want to remove a package with dependencies then you can copy the following command:

sudo pacman -Rs cmatrix
EXPLANATION
  • -Rs: Option to remove package with dependencies.

Remove a package with its dependencies with pacman

Another way to remove packages with dependencies is to use the -Rcns option. Check the following command:

sudo pacman -Rcns vlc
EXPLANATION
  • -Rs: Option to remove a desired package.
  • -c: Remove all the packages that depend on that specific package also.

Remove all dependencies and packages that depends on the package

Tips: As there are many removal options like -R,-Rs, Rns, Rcns.It is not recommended to uninstall packages using -Rcns as it can remove other packages that are important for the system. So if it is needed to use the option to remove a package then the user should carefully use it.

How to Remove Multiple Packages

With Pacman you can remove multiple packages. To do this, copy the following command:

sudo pacman -R vlc cmatrix
EXPLANATION
  • -R: Option to remove the desired package.
  • vlc, cmatrix: The packages that I want to remove.

Remove multiple packages with pacman

Updating And Upgrading With Pacman

One important function of a package manager is to update the packages. With pacman, you can update the full system and also single and multiple packages. Here below I have shown how to use the update command:

Update the System Using Pacman

If you want to update your system with one command then you can use the following command:

sudo pacman -Sy
EXPLANATION
  • -Sy: Option to update the system.

Update the system with pacman

It will show whether the system needs to be updated or not. As here we can see it has shown the system is up to date.

Upgrade the System With Pacman

If the upgradable version is available then the upgrade command will download the upgraded version. You can copy the following command:

sudo pacman -Syu
EXPLANATION
  • -Syu: Option to upgrade the system.

Upgrade the system with pacman

To confirm the upgraded version, you have to press the Y and ENTER.

How to Update a Single Package

To upgrade a single package, first, you have to upgrade the system with the following command:

sudo pacman -Syu

After using the command you can now upgrade a single package using the following command:

sudo pacman -S vlc
Tips: When the user upgrades a single package he should use the -Syu option and then the -S [package name] option. Using the -Sy option instead of using -Syu is not recommended.

How to Search for a Package With Pacman

If you want to search or locate a package in the system then you can use the following command:

sudo pacman -Ss auditing
EXPLANATION
  • -Ss: Option to locate a package in the repository.
  • auditing: The package that I have searched for.

Search for a package with pacman

Search for a Package That Owns a File in Linux

To search for the file that has been owned by a package you can copy the following command:

sudo pacman -F pacman
EXPLANATION
  • -F: Option to search for the file.
  • pacman: The key or pattern of the file name that I want to search.

Display which package owns files

By this command, you can search for any required files in the package repository.

Clean Pacman Cache in Arch Linux

Pacman does not delete the packages permanently and it stores all the packages including the installed and uninstalled packages in the /var/cache/pacman/pkg. With this process, the memory will be full. So below I have shown how to clean the files.

Cleaning All the Package Cache

To remove the old unused installed and uninstalled packages and all cached packages from the cached directory you can use the following command:

sudo paccache -r
EXPLANATION
  • paccache: Remove packages from the cache directory.
  • -r: Option to remove the old unused packages from the cache.

Remove all package cache with pacman

How to Remove All Cached Packages

If you want to remove all the cached packages that are not installed then you can copy the following command:

sudo pacman -Sc
EXPLANATION
  • -Sc: Option to clean all cache packages.

Remove all cache packages that is not installed

How to Remove All Cached Packages With Dependencies

Sometimes some packages can not be removed because of the dependency issue. So if you want to remove all the files then you can use a more aggressive way for which you have to use the -Scc option. To remove all the cached packages forcefully you can copy the following command:

sudo pacman -Scc
EXPLANATION
  • -Scc: Option to clean all the cached packages aggressively.

forcefully remove all cache packages with pacman

Query of Packages In Arch Linux

Pacman provides a query option that you can use to know about the package details. Below I have shown how to manage a package with the query option.

Listing All Installed Packages With Pacman

If you want to list all the available packages in the repositories then you can copy the following command:

sudo pacman -Q
EXPLANATION
  • -Q: Ouery of all packages in the database and show the list.

List of all packages with pacman

List of all installed packages with pacman extended

So from the image, you can see the package list that is available in the system.

How to List Explicitly Installed Packages

If you want to list the explicitly added packages then you can use the following command:

sudo pacman -Qe
EXPLANATION
  • -Qe: Option to list the explicitly installed packages.

List of explicitly installed packages with pacman

Here if you want to see which explicitly installed packages are not needed as dependencies then you can copy the following command:

sudo pacman -Qet
EXPLANATION
  • -Qet: Option to list the explicit packages that are not needed for any other packages.

List of all Explicitly installed packages that are not needed by any other packages

List of All Packages with Only Name

From the above examples, you can see that all the packages have been seen with the name and version. If you want to see only the package name then copy the following command:

sudo pacman -Q | awk '{print $1}'
EXPLANATION
  • -Q: Option to list the installed packages.
  • awk: Extract a specific package.
  • (|) pipe: Creates a unidirectional data channel that can be used for interprocess communication.
  • {print $1}: Print the first column.

List all the installed packages only with name with pacman

Showing the Orphaned Dependencies

To see the orphaned package dependencies you can copy the following command:

sudo pacman -Qdt
EXPLANATION
  • -Qdt: Option to query the orphaned dependency packages.

Display all the orphaned package dependencies

How to Save a File of Installed Packages

If you want to save the package lists from the query then you can use the following command to copy it.

sudo pacman -Qe > recentpackage.txt
EXPLANATION
  • -Qe: Option to list the recently installed packages.
  • > recentpackage.txt: Redirect the output into the txt file recentpackage.txt.

Save the package list pacman

File added that has been shown

From the above image you can see in the home section the file has been saved. I opened the file to see whether it was saved in the package list.

The txt file has been shown

So, you can see the package list has been saved into the txt file.

Showing Package Information

If you want to see package information you can copy the following command:

sudo pacman -Qi vlc
EXPLANATION
  • -Qi: Option to query the information of the following package.
  • vlc: The package I want to query for information.

Display package Information with pacman

The information panel shows the dependencies that the package depends on and also the optional dependencies.

Check a Specific Package Whether It is Installed or Not

When one wants to see whether a package is installed or not then he can copy the following command:

sudo pacman -Q vlc
EXPLANATION
  • -Q: Option to query of a package.
  • vlc: The package I want to see whether it is installed or not.

Show whether a package is install or not

If the following package is not installed in the system then you will get not found comment.

How to List Files Installed With a Specific Package

To list the files that have been installed with a package you can copy the following command:

sudo pacman -Ql cmatrix
EXPLANATION
  • -Ql: Option to query the list of files that are installed with a package.
  • cmatrix: The package which files I want to see.

List of all files that owned by a package

Configuration With Pacman

If you want to specify the function or want to customize the command according to your preference then you can edit the configuration file. To edit the configuration file first, you have to open the file. To open the configuration you can copy the following command:

nano /etc/pacman.conf
EXPLANATION
  • nano: Text editor that provides some advanced features to edit the files.
  • /etc/pacman.conf: Path of the configuration file.

Edit the configuration file with pacman

Here the configuration file has been opened.

Showing the configuration file

Specify the package configuration with pacman

In this configuration file, you can see the parameters that you can edit according to your desire. If you want to download multiple packages parallelly then you have to uncomment the option in the misc option section and have to put a positive integer as shown in the image is 5. If you want to see the old and new versions of the packages then you have to uncomment verbosePkglists.

Above the misc option, you can see some other options.

If you want to exclude a package from upgrading, then uncomment the options and type your desired package name as follows:

IgnorePkg=cmatrix

Again when you want to ignore a group of packages then you can uncomment the IgnoreGroup and name a group of packages.

After editing the configuration file you have to save the changes by pressing CTRL+O and then press the ENTER key. After that press the CTRL+X option.

Common Issues With Pacman

There are some common problems that arise while working with Pacman. Among them two problems are shown below:

[Solved] Invalid option –overwrite?

To install or upgrade a package sometimes the –force option is used when the user is not bothered about the errors and wants to proceed with the process.

While using the –force it shows that this option is deprecated and it is recommended to use the –overwrite option as the following command shows:

sudo pacman -S --overwrite <package name>

But if one uses the overwrite option in the same way as shown above, he also faces the error of an invalid option. So use the overwrite option in this pattern and hope It will work properly.

sudo pacman -S --overwrite \* <package_name>

How to remove broken package dependencies?

If you want to remove the broken packages then firstly you have to use the following command:

sudo pacman -Rs <package name>

This -Rs will remove a package with all its dependencies. If it is not solved then you can use the option to get rid of all packages that you need.

sudo pacman -Rd <package name>

After removing the packages run the upgrade command:

sudo pacman -Syu

After all this process, reinstall the broken packages with the installation option:

sudo pacman -S <package name>

Conclusion

In this article, I have tried to show the basic information and commands of the Pacman package manager.  So, for the beginner, it is very difficult to memorize the syntax of the command as the syntax is not so user-friendly in my opinion. Hope after reading the article one will be able to manage the Pacman package manager easily.

People Also Ask

Why use Pacman package manager?

The reason for using Pacman is to make it easy to manage packages. It is also used for its speed, customizability, and reliability. These features mainly make Pacman a popular choice for Arch-based distributions and its derivations.

Why pacman is a faster package manager than APT?

Pacman is lightweight, simple, and has fewer features than apt and it is written completely in C language. These are mode Pacman a faster package manager.

What are the differences between rolling release and standard release as the rolling release is applied on arch-Linux?

Standard release means the fixed release and Rolling release means continuous release or up-to-date the system continuously. In the rolling release, there is no need to reinstall a package, always update packages automatically. If you want to reinstall then you have to install it with a rolling release system.

Why one downgrade package?

When there are version conflicts that result in dependency errors then one needs to downgrade a package. To downgrade a package you use the command sudo pacman -U /var/cache/pacman/pkg/package name. Here you have to replace the package name with your desired package and use the full name.


Related Articles


<< Go Back to Package Manager Examples | Package Management in Linux | Learn Linux Basics

4.7/5 - (3 votes)
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
icon linux
Afia Zahin Oishi

Assalamualaikum, I am Afia Zahin, completed my graduation in Biomedical Engineering from Bangladesh University of Engineering and Technology, currently working as a Linux Content Developer Executive at SOFTEKO. A high achieving professional with a strong work ethic and able to work in a team in order to consistently achieve my goal and build my skillset. Able to handle difficult problems with patience and swift decision-making. Read Full Bio

Leave a Comment