There are multiple way on how to determine whether a specific package is already installed on your system. The first dpkg
command will list all currenlty installed packages on your system:
# dpkg -l
From here we can search for a specific package by supplying the package name as an argument:
# dpkg -l hello Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=================-=============-=============-======================================== ii hello 2.9-2+deb8u1 amd64 example package based on GNU hello
From the above dpkg
‘s command output we can conclude that hello
package is currently installed our system. In case that the about dpkg
output would not produce any output means that the package hello
is not installed. In the situation that we do not exactly know the name of the package we are searching for we can use meta characters to match possible name.
# dpkg -l 'h*' Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=================-=============-=============-======================================== ii hello 2.9-2+deb8u1 amd64 example package based on GNU hello un hello-debhelper(no description available) un hello-traditional (no description available) un hoogle (no description available) un hostapd (no description available) ii hostname 3.15 amd64 utility to set/show the host name or dom un hurd (no description available)
However, in this case we also list uninstalled un
packages. To list only installed package we can pipe the output to grep:
# dpkg -l 'h*' | grep ^ii ii hello 2.9-2+deb8u1 amd64 example package based on GNU hello ii hostname 3.15 amd64 utility to set/show the host name or domain name
Another alternative to the above dpkg
command is to use the -s
status option. For example:
# dpkg -s hello