How to Use Pacman in Arch Linux

Arch Linux constitutes a complex distribution of Linux, making it a grueling Linux operating system. Programmers that do not have a strong command over Arch Linux usually opt for other distributions. The prominent distinction among Arch Linux and its other distributions is Pacman. Pacman is a package manager that buffs package usage in Arch Linux. It flattens the use of packages, both from the repository and the ones that you build on your own. Pacman incorporates a set of commands that ease the manipulation of Arch-based packages in the Arch Linux distribution. Pacman also contains binary packages to assist in the creation of a package build. In other Linux distributions, you comply with the apt command; while in Arch Linux, Pacman commands can come in handy for more efficient management of the system repository and build.

This guide shares some basic knowledge about Pacman for beginners and professional programmers alike. It covers all the domains that you might need while operating in Arch Linux with Pacman. These commands can help make the management of your Arch-based packages in Linux more efficient and convenient.

Requisite Pacman Commands

If you are operating Pacman on Arch Linux, then to boost the usage of this dynamic package manager, you must be aware of the following commands:

  • Installing a package with Pacman
  • Removing installed packages
  • Upgrading a package
  • Searching for a package
  • Cleaning the package cache
  • Installing a local package
  • Troubleshooting

These commands encompass the usage of Pacman proficiently and are the prominent commands you might need to understand to tackle using Pacman.

Installing a Package with Pacman

It is a primary domain that you will opt for after selecting the Arch Linux package manager. To get software from the system repository or build a package, the first step is to install it using Pacman. The Pacman command for installing single or multiple packages is as follows:

$ pacman -S _package_name1_ _package_name2_ ...

The last set of dots represents continuity in the command. You will need to replace the package name in the above command to install it on your system. Sync the installed package before classifying it as a dependency or explicitly installed package through the -S and -U commands.

Removing Installed Packages

To remove an installed package in Arch Linux, you have three main options:

  1. Remove the package only
  2. Remove the package along with its dependencies
  3. Remove the dependencies only

To remove the package only, issue the following command:

$ pacman -R package_name_


-R signifies the removal command.
To remove the package along with its dependencies, issue the following command:

$ pacman -Rs _package_name_


To remove dependencies from your server, issue the following command:

$ pacman -Qdtq | pacman -Rs

Upgrading a Package

In other Linux distributions, the apt command performs package updating. In Arch Linux, a single command in Pacman not only updates but also syncs and refreshes system packages. The following command upgrades configured packages only and does not update local packages available on the system:

$ pacman -Syu


Here, -y refreshes the system and -u is for package upgrading. The literal meaning of this command is to sync the package with the database of the main server, then refresh the package connected to the database. Lastly, this command updates the package if an update is available. Keep in mind that you must opt for full updates, as partially updated packages are not compatible with Arch Linux.

Search for a Package

Pacman is also efficient in searching the packages in your server database based on the name and description of the required package.

$ pacman -Ss _string1_ _string2_


If you are looking for a package that already exists in your system, then apply the following code. You can add other strings in this code after string2 simultaneously.

$ pacman -Qs _string1_ _string2_


-Q symbolizes the package search in the local database.

$ pacman -F _string1_ _string2_


-F finds the remote packages in the database.

Cleaning the Package Cache

In Arch Linux, Pacman does not delete previously installed packages from its storage. So, you will need to input the following command to clear the cache of your database. This command deletes unsynchronized packages.

$ pacman -Sc


To clear all the files in the cache, input the following command:

$ pacman -Scc

Installing a Local Package

When using Pacman, you only need to install local and remote packages outside the jurisdiction of the server repository. The following code will install the local package after searching the remote depository.

$ pacman -U _/path/to/package/package_name-version.pkg.tar.xz_
$ pacman -U http://www.example.com/repo/example.pkg.tar.xz


The second code can install the remote packages that do not exist in the official depository.

Troubleshooting

You may confront any of the following three error types while working with Pacman in Arch Linux:

  • Conflicting file error
  • Invalid package
  • Locking database

The conflicting file error occurs due to the presence of a conflicting file in the repository. You can either rename the file manually or force the overwrite function. The following command is used for the overwrite function:

$ pacman -S --overwrite glob package

The invalid package error surfaces due to the partial update of the package. It is better to look for the package description before installing it.
The locking database error occurs due to an interruption in altering the database.

$ lsof /var/lib/pacman/db.lck


Run the above command to detect the clash in the locking process. And then, you can return to locking the database.

Conclusion

Pacman is the package manager of Arch Linux that assists in the installation and management of packages and build systems. If you follow this guide, then it will be easy for you to operate Pacman with maximum efficiency in your Arch Linux system. This guide has covered most of the commands that you need to know when using Pacman.



from Linux Hint https://ift.tt/3nQIxtT

Post a Comment

0 Comments