Loading...
X

How to check if a package is installed on Linux Mint

All Linux distributions consist of the same components: kernel, display manager, graphical desktop environment, pre-installed programs. To make users somehow distinguish distributions from each other, their builders install different wallpapers and add their own programs.

Unfortunately, the desire of distributors to stand out and become more “friendly” to the user leads to ridiculous (let's say bluntly, idiotic) problems. And, most likely, you already guessed about it from the title of this article.

Any distribution that is derived from Debian uses the apt file manager. To find out if a particular package is installed, just use the apt search command and specify the package name:

apt search PACKAGE

For example, I am wondering if kernel headers are installed already:

apt search linux-headers-

Well, the command is poor, because there are many different kernels, let's issue a more specific one and ask the question “are the headers of the current kernel set”:

apt search linux-headers-`uname -r`

Can you answer whether this package is installed or not? In fact, the answer is present but not clear, because instead of the original program, the file /usr/local/bin/apt is used, which is a Python script using the aptitude (!) program, the output format is completely different from the one we are expecting.

The answer is in the very first column, where there is only one character. The meaning of the characters is as follows:

  • p, meaning that no trace of the package exists on the system,
  • c,meaning that the package was deleted but its configuration files remain on the system,
  • i, meaning that the package is installed, and
  • v, meaning that the package is virtual.

How to use apt instead of aptitude on Linux Mint

For many years I have been working with the apt program, and aptitude is not installed at all on many distributions derived from Debian. Therefore, the original apt program is much more familiar to me.

To use apt instead of aptitude, run a command of the form:

/usr/bin/apt search PACKAGE

For instance:

/usr/bin/apt search linux-headers-`uname -r`

Well, that’s exactly what I wanted, brief information about the package with the unambiguous inscription “[installed]”:

Always issue /usr/local/bin/apt is inconvenient, so the question arises, how to get rid of this idiotic Python script? It is enough to run the command:

sudo mv /usr/local/bin/apt /usr/local/bin/-apt

And now a program of the form:

apt search PACKAGE

will give exactly the result that you expect.

For instance:

apt search linux-headers-`uname -r`

If you want to return the script back, then simply run the command:

sudo mv /usr/local/bin/-apt /usr/local/bin/apt

Leave Your Observation

Your email address will not be published. Required fields are marked *

Scroll Up