Computer

New to Linux? Domina Pacman, a complete package manager

Pacman, the alternative to APT on Linux

One of the package managers The most used, especially outside the Debian realm, is Pacman. Although if we come from other managers, such as APT, it may be difficult for us to get used to it at first, in reality it is a fairly simple and intuitive package manager. It is enough to know what are the main commands and parameters that we may need to be able to control our Linux system without problems.

Pacman is the default package manager for Arch Linux, and other distributions based on it, such as Manjaro, Parabola, Frugalware and Chakra, among others. The files and directories that this package manager needs and uses to function are as follows:

  • Configuration: /etc/pacman.conf
  • Cache path: / var / cache / pacman / pkg /
  • Package database: / var / lib / pacman / sync
  • Log (to see errors): /var/log/pacman.log

Next, we will see how to use this tool. If you need more detailed information, we can consult the official Pacman help found at this link.

Commands to update

Although the possibilities offered by this package manager are very great, we are going to see what are the basic and essential functions that we can perform with it, starting with updating the repositories and the system.

Update the package database (the repositories)

The first thing we are going to do is see how search for new versions of the database system packages. The package manager will read the “pacman.conf” file, and will look there for new versions of this database to copy to the PC. To do this, all we have to do is run the following command:

sudo pacman -Syy

The “-S” parameter takes care of synchronizing the packages, the first “y” downloads the updated package database, and the second “y” forces the download, even if it is already up to date.

Update the whole system

Once we have the package database downloaded and synchronized with our PC, the next thing we can do is update our whole system. To do this, all we have to do is run the following command:

pacman -Syu

This command will compare the packages of our PC with those of the last database downloaded and synchronized on the PC. Then it will download the new versions of the outdated packages and install them on the PC. We may need to reboot to get our system fully up to date.

Update a program

If what we only want is update one of the programs or packages that we have installed on the PC, what we can do is execute the following command:

pacman -S paquete

What this command will do is compare the version of Firefox (for example) that we have on our system, compare it with the one in the package database and, if there is a newer one, download the new version.

Find and install programs

Another of the utilities that we can give to this package manager is to search, download and install all kinds of programs from the software lists that we have added to it.

Find a program

If we do not know the package name of a specific program, we can look for it in the repositories. We must execute the following command in a terminal window to look for any match in both the package name and its description.

pacman -Ss paquete

Pacman will also allow us to search for a specific package within the repositories, if we already know its name, to see all the details of it, as well as its dependencies. We can do this easily by executing the following command, entering, yes, the exact name of the package:

pacman -Si paquete

Install a program

One of the most essential commands and that we will use the most, along with updating, is that of install a new program. We simply have to execute the following parameter:

sudo pacman -S paquete

This command will be in charge of looking for a match of the name of the package that we have introduced, downloading the latest version of it and installing it on our Linux. All this automatically.

Download and install packages separately

If we do not want the process to be automatic, we can also do it manually step by step. To do this, what we must do first is execute the following command:

sudo pacman -Sw paquete

This command will download the package that we have indicated from the repositories, and will save it (by default) in / var / cache / pacman / pkg. Once downloaded, we can install said package by executing another command:

sudo pacman -U ruta_al_paquete

Uninstall a program

If we no longer need to have a program installed, and we want to free up space, we can uninstall it. To do this, what we must do is execute the following:

sudo pacman -R paquete

This command will be in charge of deleting the program that we have indicated. Of course, it will leave its dependencies intact, even if there are no other programs that need them. If we want to delete all orphaned dependencies, we can do it in a simple way by changing the “-R” parameter of the previous command to “-Rsun”.

View the details of an installed program

The following command will allow us to know in detail all the packages, and their dependencies, that we have installed on the system:

pacman -Qi paquete

Other advanced commands

But this is not the only thing that Pacman allows us to do. This package manager offers us many more options and possibilities with which we can have total control over our system. Some of the possibilities that we will find are:

Reinstall all packages

Do you have problems with the distro? Have some packages stopped working? Instead of formatting and installing again, we can use Pacman to repair the system. To do this, we will simply execute the following command in the terminal:

pacman -Qnq | pacman -S -

This command will search for all the packages that we have installed on the computer and will download them again forcing their update. There may be a large number of packages and programs installed on the PC, so this process can be time consuming and use a lot of internet data.

See all installed packages and programs

If what we want is to see a list with everything we have installed on our system, what we can do is execute the following command in the terminal:

pacman -Q

This command offers many variations that allow us, for example, to copy its results to a text document, or to filter packages.

Clean the system

As we use the package manager, it takes up more and more space in our system. And in the long run we can notice that this is slow. Therefore, it never hurts to clean up to erase all the cache, temporary files and junk files that have remained on our PC.

To do this, what we can do is open a console and execute the following command:

sudo pacman -Scc

Clever. Now we will have deleted all the junk and unnecessary files from Pacman, freeing up a good amount of space.

Related Articles