August 26, 2023

Check whether a package is installed on GNU/Linux

$ dpkg -s package

asks Debian’s package manager to check the status of a package.

For example:

$ dpkg -s okular

prints:

dpkg-query: package 'okular' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.

which shows that okular is not installed.

Conversely:

$ dpkg -s git | grep install
Status: install ok installed

shows that git is installed. Note: pipe the output of the command to grep with the keyword install to suppress superflous.

Here is a mnemoic to remember this command: dpkg is Debian’s (d) package (pkg) manager and -s is a substitue for --status.

You can also use option list of apt, the command-line interface for the package management system:

$ apt list --installed package

For example:

$ apt list --installed git
Listing... Done
git/nabia-security,now 1:2.25.1-1ubuntu3.11 amd64 [installed]
N: There are 2 additional versions. Please use the '-a' switch to see them.

tells us that git is installed.

To learn more about dpkg and apt, run:

$ man dpkg
$ man apt

See also:


personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88