This post will guide you how to check if package is installed on CentOS/RHEL/Ubuntu Linux. How to find if a package is installed or not in CentOS/RHEL/Ubuntu Linux system. How to List all installed packages in your Linux operating system.
Check If Package Is Installed in Linux
Before installed one package, you need to check if this package is installed already or not in your Linux system. So How to check the installed packages in the different Linux distribution. Let’s see the following introduction.
For CentOS/RHEL Linux
If you are using CentOS/RHEL Linux, and you want to check if a specific package is installed or not, you can use the rpm command with -qa option to achieve the result. Type the following command to check if httpd package is installed or not:
$ rpm -qa | grep httpd
Outputs:
[root@osetc_test ~]# rpm -qa | grep httpd httpd-tools-2.2.15-59.el6.centos.x86_64 httpd-tools-2.2.15-60.el6.centos.6.x86_64 httpd-2.2.15-60.el6.centos.6.x86_64
From the above outputs, you can know that the httpd package has been installed in your system, and the installed version of httpd is 2.2.15-60.
You can also use the yum command to achieve the same result, type:
$ yum list installed httpd
Outputs:
[root@osetc_test ~]# yum list installed httpd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.sonic.net * epel: mirror.sjc02.svwh.net * extras: mirror.fileplanet.com * updates: mirror.sjc02.svwh.net Installed Packages httpd.x86_64 2.2.15-60.el6.centos.6 @updates [root@osetc_test ~]#
List All Installed Packages
If you want only to list all installed packages in your CentOS/RHEL linux, you can use one of the following command:
$ rpm -qa
Or
$ yum list installed
For Ubuntu/Debian Linux
If you are using Ubuntu/Debian Linux, and you can use the dpkg command to find out a package is installed or not. type the following command to check if httpd package is installed or not:
$ dpkg -s httpd
Outputs:
devops@devops-osetc:~$ dpkg -s httpd dpkg-query: package 'httpd' is not installed and no information is available Use dpkg --info (= dpkg-deb --info) to examine archive files, and dpkg --contents (= dpkg-deb --contents) to list their contents.
From the above outputs, you should know that the httpd package is not installed in your Ubuntu Linux system.
Let’s see another example to check if wget package is installed or not, type:
$ dpkg -s wget
Outputs:
devops@devops-osetc:~$ dpkg -s wget Package: wget Status: install ok installed Priority: important Section: web Installed-Size: 880 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Architecture: amd64 Multi-Arch: foreign Version: 1.17.1-1ubuntu1.1 Depends: libc6 (>= 2.17), libidn11 (>= 1.13), libpcre3, libssl1.0.0 (>= 1.0.1), libuuid1 (>= 2.16), zlib1g (>= 1:1.1.4) Recommends: ca-certificates Conflicts: wget-ssl Conffiles: /etc/wgetrc c43064699caf6109f4b3da0405c06ebb Description: retrieves files from the web Wget is a network utility to retrieve files from the web using HTTP(S) and FTP, the two most widely used internet protocols. It works non-interactively, so it will work in the background, after having logged off. The program supports recursive retrieval of web-authoring pages as well as FTP sites -- you can use Wget to make mirrors of archives and home pages or to travel the web like a WWW robot. . Wget works particularly well with slow or unstable connections by continuing to retrieve a document until the document is fully downloaded. Re-getting files from where it left off works on servers (both HTTP and FTP) that support it. Both HTTP and FTP retrievals can be time stamped, so Wget can see if the remote file has changed since the last retrieval and automatically retrieve the new version if it has. . Wget supports proxy servers; this can lighten the network load, speed up retrieval, and provide access behind firewalls. Homepage: https://www.gnu.org/software/wget/ Original-Maintainer: Noël Köthe <noel@debian.org>
You can also use the dpkg-query command to achieve the same result of checking the package is installed or not, type:
$ dpkg-query -l 'wget' $ dpkg-query -l 'httpd'
Outputs:
devops@devops-osetc:~$ dpkg-query -l 'wget' 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 wget 1.17.1-1ubuntu1.1 amd64 retrieves files from the web devops@devops-osetc:~$ dpkg-query -l 'httpd' dpkg-query: no packages found matching httpd
List All Installed Packages in Ubuntu
If you want to list all installed packages in Ubuntu Linux, you can use one of the following command:
$ dpkg -l
Or
$ dpkg-query -l