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 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:
To list all the packages installed as file dependencies, use -Qd option:
View all the orphan packages that are not needed by any other package as:
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.
Similarly, user can also search for the list of dependency-free packages:
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:
Lastly, find all the files installed by the package with their location details as follows:
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.
Pacman also allows updating all the packages except for specific software that user want to keep at an old version as follows:
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:
Now, use the basic syntax to install the package:
To ensure system update before package installation use:
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:
Install package from the cache folder:
To install package from Manjaro mirror:
Use an -R flag to remove packages without uninstalling unneeded dependencies:
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:
Pacman creates backup files during package removal, use the -n flag in any of the above commands to remove those files, for instance:
Lastly, remove all the orphan packages and their configuration files as below:
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:
Or to entirely clean the cache
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.
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:
Each repository in the above file has a section name in square brackets, in the following format:
#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.
SigLevel = PackageRequired
Include = /etc/pacman.d/core
#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.
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.