Sometimes we find that we need to know if any program or package is installed in the system or not. The problem is that with the amount of package managers available for the different GNU / Linux distributions, this can be somewhat complicated for newbies as they have to remember the different commands or tools as well as their options in each case so that we show if the package is in our system.
For example, if we move on Arch Linux and derivatives, the tool we are looking for is the package manager pacman with the -Qs options and the name of the package we want to check. On the other hand, if it is a distro based on RPM packages, we can use the rpm -qa tool that lists all the installed packages and pipe the output with the help of a pipe towards grep package-name to filter the result. For Debian and derivatives you can use dpkg -s followed by the name of the package to consult, etc.
You may think that which is a generic solution for any distribution, and the truth is that it would work up to a point, since not all packages are found in the paths where which search and therefore it may seem that if we look for certain software packages it seems that they have not been found and are not installed in the system but they are ... For example, if we look if the nano text editor is installed with which we can see perfectly if It is there or not, but if we test it with LibreOffice the thing varies:
which nano which libreoffice
The result of both will be very different, since in the first case it will indicate the path of the binary (/ bin / nano) and in the second it will not show us any output even if LibreOffice is installed. That is what I meant. Therefore, in the end we have no choice but to learn the different commands and options for the distro we are using:
pacman -Qs nombre-paquete rpm -qa | grep nombre-paquete dpkg -s nombre-paquete