FUNDAMENTALS A Complete Guide for Beginners
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.
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
- 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.
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.
To the confirmation of installation, the user must press Y and ENTER.
How to Install Multiple Packages Using Pacman
You can install multiple packages with Pacman at a time. To install multiple packages with Pacman, copy the following command:
sudo pacman -S vlc cmatrix python
- vlc, cmatrix, python: The packages that I want to install.
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
- -U: Option to install a package locally.
- /home/oishi/Downloads/zoom_x86_64.pkg.tar.xz: Path where the downloaded packages are stored.
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
- pactree: Option to display the dependency tree of the following package.
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
- -R: Option to remove the desired package from the repository.
- cmatrix: The package that I want to remove.
To confirm the removal of the package, you must press Y and then Enter.
How to Remove a Package With Its Dependencies
While removing a package, the package manager checks whether other packages depend on it or not. If there are no dependencies on the package which has been removed, then the package manager also removes all the package dependencies. To remove a package with dependencies, copy the following command:
sudo pacman -Rs cmatrix
- -Rs: Option to remove package with dependencies.
Another way to remove packages with dependencies is to use the -Rcns option. Check the following command:
sudo pacman -Rcns vlc
- -Rs: Option to remove a desired package.
- -c: Remove all the packages that depend on that specific package also.
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 may be 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 cmatrix vlc
- -R: Option to remove the desired package.
- vlc, cmatrix: The packages that I want to remove.
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
- -Sy: Option to update the system.
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
- -Syu: Option to upgrade the system.
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
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
- -Ss: Option to locate a package in the repository.
- auditing: The package that I have searched for.
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
- -F: Option to search for the file.
- pacman: The key or pattern of the file name that I want to search.
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
- paccache: Remove packages from the cache directory.
- -r: Option to remove the old unused packages from the cache.
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
- -Sc: Option to clean all cache packages.
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
- -Scc: Option to clean all the cached packages aggressively.
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
- -Q: Ouery of all packages in the database and show the list.
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
- -Qe: Option to list the explicitly installed packages.
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
- -Qet: Option to list the explicit packages that are not needed for 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}'
- -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.
Showing the Orphaned Dependencies
To see the orphaned package dependencies you can copy the following command:
sudo pacman -Qdt
- -Qdt: Option to query the orphaned dependency packages.
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
- -Qe: Option to list the recently installed packages.
- > recentpackage.txt: Redirect the output into the txt file recentpackage.txt.
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.
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
- -Qi: Option to query the information of the following package.
- vlc: The package I want to query for information.
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
- -Q: Option to query of a package.
- vlc: The package I want to see whether it is installed 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
- -Ql: Option to query the list of files that are installed with a package.
- cmatrix: The package which files I want to see.
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
- nano: Text editor that provides some advanced features to edit the files.
- /etc/pacman.conf: Path of the configuration file.
Here the configuration file has been opened.
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
Some common problems 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
- How to Use DNF Package Manager in Linux [A Complete Guide]
- How to Use Yum Package Manager in RHEL [A Total Guide]
- A Total Guide on RPM Package Manager in Linux
- Apt Package Manager [A Complete Guide on How to Use it]
- The Synaptic Package Manager [A Complete Guide]
<< Go Back to Package Manager Examples | Package Management in Linux | Learn Linux Basics