본문 바로가기
Linux

find out if package is installed in linux

by 공대우냉이 2016. 1. 5.

The command to finding out if package is installed in Linux is depend upon your Linux distribution. Following are commands for different distributions.


se dpkg command, which is package manager for Debian. Suppose you want to find out package apache-perl or sudo is installed or not, type command:
$ dpkg -s apache-perl
OR
$ dpkg -s sudo
Output:

Package: sudo
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 396
Maintainer: Bdale Garbee
Architecture: i386
Version: 1.6.8p12-4
Replaces: sudo-ldap
Depends: libc6 (>= 2.3.5-1), libpam0g (>= 0.76), libpam-modules
Conflicts: sudo-ldap
Conffiles:
/etc/pam.d/sudo e3aaa79c2a00244cdfd17117127f8993
/etc/init.d/sudo 64f882a713108e70dc6133444177281f
Description: Provide limited super user privileges to specific users
Sudo is a program designed to allow a sysadmin to give limited root
privileges to users and log root activity.  The basic philosophy is to give
as few privileges as possible but still allow people to get their work done.
.
This version is built with minimal shared library dependencies, use the
sudo-ldap package instead if you need LDAP support.

Use file /var/lib/dpkg/available to find out all package names available to you. Or you can use following command (list all packages in /var/lib/dpkg/status):
$ dpkg-query -l
You can also try to match package name using wild cards:
$ dpkg-query -l 'libc6*'
Once you've found package name, use the following command to get exact status (whether it is installed or not):
$ dpkg-query -W -f='${Status} ${Version}\n' apache-perl
Output:

install ok installed 1.3.34-2

============================================================================

Reference

http://www.cyberciti.biz/faq/find-out-if-package-is-installed-in-linux/