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


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.


$ 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. © 2016-2023 Content is licensed under CC BY-NC-SA 4.0 .