Manjaro Linux

Introduction to Manjaro Package Manager Pacman

The Linux distributions package management system has covered a long way. The timely practice of software management by creating independent repositories, application packages, and installation tools made software accessible across environments. Similar to all other Linux distributions, Manjaro has a default package manager of Arch Linux.

In this article, we learn to use the command-line package manager Pacman to add, remove, and update software packages from the distribution or user build repository. The tutorial also covers how to query details of installed packages on the system.

Pacman

Pacman ships with all Manjaro’s editions and includes some advanced features not available in its GUI Pamac. By default, it installs packages from Manjaro independent repository. However, it does not support community build packages from Arch User Repository (AUR).

Query Installed Packages

Pacman provides various ways for the user to view the already installed explicit and orphan packages, etc. To get started, lets first use the -Q flag to view already install packages with their version number:

manjaro@manjaro:~$ pacman -Q

a52dec 0.7.4-11
aalib 1.4rc5-14
accounts-qml-module 0.7-3
accountsservice 0.6.55-3
…………...

To list all the packages installed as file dependencies, use -Qd option:

manjaro@manjaro:~$ pacman -Qd

View all the orphan packages that are not needed by any other package as:

manjaro@manjaro:~$ pacman -Qdt

The t option lists only true orphans, whereas the d option lists optionally required packages.

Pacman also allows viewing packages that are explicitly installed by the user, not the package dependencies.

manjaro@manjaro:~$ pacman -Qe

Similarly, user can also search for the list of dependency-free packages:

manjaro@manjaro:~$ pacman -Qet

Pacman also enables the user to view further details of already installed packages such as package build and group, release number, and installation date, etc, by using the following syntax:

manjaro@manjaro:~$ pacman -Qi <package_name>

Lastly, find all the files installed by the package with their location details as follows:

manjaro@manjaro:~$ pacman -Ql <package_name>

Install Updates

Before package installation, synchronize system packages with the Manjaro official database to retrieve the latest release. Use the following command to synchronize, refresh, and upgrade all packages in the system.

manjaro@manjaro:~$ pacman -Syu

Pacman also allows updating all the packages except for specific software that user want to keep at an old version as follows:

manjaro@manjaro:~$ pacman -Syu --ignore=<package_name>

Package Installation

Update the system as above, as package installation without system update in a rolling release can cause a partial upgrade issue.

The package manager allows searching for available packages in the Manjaro repository. All it requires is the package keyword to output the package name and all of its details. Use the Pacman command with -Ss option as follows:

manjaro@manjaro:~$ sudo pacman -Ss <keyword>

Now, use the basic syntax to install the package:

manjaro@manjaro:~$ sudo pacman -S <package_name>

To ensure system update before package installation use:

manjaro@manjaro:~$ sudo pacman -Syu <package_name>

Manjaro package manager enables package installation directly from the local file system or directly from Manjaro’s mirror. The feasibility to install packages from the Pacman cache leads to another Pacman feature of only downloading packages to the /var/cache/pacman/pkg directory.

Download package to cache:

manjaro@manjaro:~$ sudo pacman -Sw <package_name>.pkg.tar.xz

Install package from the cache folder:

manjaro@manjaro:~$ sudo pacman -U /var/cache/pacman/pkg/<package_name>.pkg.tar.xz

To install package from Manjaro mirror:

manjaro@manjaro:~$ sudo pacman -U https://mirror.alpix.eu/manjaro/stable/community/x86_64/<package_name>.pkg.tar.xz

Package Removal

Use an -R flag to remove packages without uninstalling unneeded dependencies:

manjaro@manjaro:~$ sudo pacman -R <package_name>

To remove unrequired dependencies, use the -Rsu flag in the above command. Pacman blocks the package uninstallation process when it’s a dependency for some other package. However, removal of that package is still possible via the following command:

manjaro@manjaro:~$ sudo pacman -Rc <package_name>

Pacman creates backup files during package removal, use the -n flag in any of the above commands to remove those files, for instance:

manjaro@manjaro:~$ sudo pacman -Rsun <package_name>

Lastly, remove all the orphan packages and their configuration files as below:

manjaro@manjaro:~$ sudo pacman -Qtdq | pacman -Rns -

Pacman Cache

By default, Pacman maintains a copy of old packages in the cache. Even though it helps install the old package versions in case of emergency, it sometimes grows to a large size. Pacman offers cache cleaning options to either clear all the no longer installed cache packages:

manjaro@manjaro:~$ sudo pacman -Sc

Or to entirely clean the cache

manjaro@manjaro:~$ sudo pacman -Scc

It provides a flexible and safer way of cleaning cache by introducing a utility named paccache. By default, paccache keeps the last three versions of the package and removes the rest of them.

manjaro@manjaro:~$ paccache -rvk4

The -r operation removes cache packaged, where -v option is used to increase verbosity, and -k specifies the number of versions to keep in the cache directory. In the above command, we mention 4 to keep the last four versions of the cached packages.

Pacman Configuration File

Pacman configuration settings are inside /etc/pacman.conf file. The file can be of interest to some users as it constitutes sections representing Manjaro repositories. Use the cat command to view file content:

manjaro@manjaro:~$ sudo cat /etc/pacman.conf | less

Each repository in the above file has a section name in square brackets, in the following format:

#[repo-name]
#Server = ServerName
#Include = IncludePath

The Server directive contains a URL as a location to the repository, packages, and signatures, whereas the Include directive contains the path to the file containing lists of repository servers.

It also allows adding a path to the local directory with file:// as a prefix.

...
[core]
SigLevel = PackageRequired
Include = /etc/pacman.d/core
[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs
......

Pacman searches packages based on the order of repositories listed here. Similarly, the user can set the Usage level for each package repository. A user can add a list of tokens that enables synchronization (Sync), search, install, upgrade, or all of the features for a particular repository.

Lastly, SigLevel sets the signature verification level for each repository.

For instance, SigLevel=Optional TrustedOnly is the default setting, such that the Optional value checks if the signature is present, while the absence of it isn’t a problem. However, if the signature is present TrustedOnly value ensures it to be fully trusted. More details on the Pacman configuration file are available on the Arch Linux official website.

Conclusion

The article details various ways to query, search, update and add packages from the system or the default Manjaro repositories via Manjaro Package Manager. We also discuss the Pacman configuration file to give beginner users an overview.

About the author

Usama Azad

A security enthusiast who loves Terminal and Open Source. My area of expertise is Python, Linux (Debian), Bash, Penetration testing, and Firewalls. I’m born and raised in Wazirabad, Pakistan and currently doing Undergraduation from National University of Science and Technology (NUST). On Twitter i go by @UsamaAzad14