How to find out if package is installed in Linux

I am a new Linux system user. How do I find out if a package installed on my Linux based system using the command line option?

A Linux package is nothing but a collection of files and information about those files. Almost all software (web/database server or office app or web browser) on Linux installed using packages. The command to finding out if a package is installed in Linux depends upon your Linux distribution. Following are commands for different distributions.

Debian / Ubuntu Linux

Use dpkg command. It is a package manager for Debian/Ubuntu Linux. Suppose you want to find out package apache-perl or sudo is installed or not, type command:
$ dpkg -s apache-perl
Sample outputs:

dpkg-query: package 'apache-perl' 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.

Another example:
$ dpkg -s sudo
Sample outputs:

Package: sudo
Status: install ok installed
Priority: important
Section: admin
Installed-Size: 1692
Maintainer: Ubuntu Developers 
Architecture: amd64
Version: 1.8.20p2-1ubuntu1
Replaces: sudo-ldap
Depends: libaudit1 (>= 1:2.2.1), libc6 (>= 2.17), libpam0g (>=, libselinux1 (>= 1.32), libpam-modules, lsb-base
Conflicts: sudo-ldap
 /etc/pam.d/sudo aa40f755f85bb33c9e79bd537e2979be
 /etc/sudoers edcf6528783ecffd3f248c8089dc298e
 /etc/sudoers.d/README 8d3cf36d1713f40a0ddc38e1b21a51b6
 /etc/sudoers.dist b679ac5d1611aa9ca815224b457b2341
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 for sudoers.
Original-Maintainer: Bdale Garbee

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
Sample outputs:

install ok installed 1.3.34-2

Red Hat Enterprise / Fedora Linux / Suse Linux / Cent OS

Under Red Hat/Fedora/CentOS/Suse Linux use the rpm command:
$ rpm -qa | grep {package-name}
For example find out package mutt installed or not:
$ rpm -qa | grep mutt


If you do not see or get any outputs (package name along with version), it means the package is not installed at all. You can display or list all installed packages with the following command:
$ rpm -qa
$ rpm -qa | less

You can conditionally do something if a rpm command succeeded or failed to find package using bash shell if command:

if rpm -q $pkg
    echo "$pkg installed"
    echo "$pkg NOT installed"

On a CentOS/RHEL version 6.x/7.x and above use the following yum command to tell whether a package named htop is installed:
$ yum list installed {PACKAGE_NAME_HERE}
$ yum list installed htop

Sample outputs:

Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
Package htop-2.0.2-1.el7.x86_64 already installed and latest version
Nothing to do

If you are using Fedora Linux, try the following dnf command:
$ dnf list installed {PACKAGE_NAME_HERE}
$ dnf list installed htop

See also:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 10 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
10 comments… add one
  • Amardeep Feb 9, 2007 @ 10:06

    Hi to all,

    This is my first massage over here& i hope i will get full support.

    How to open usermap.cfg file on NetApp server?- As i have to check whether unix user login is mapped correctly with Windows login.

    As the main problem which few of the users are having is as below —

    They are NOT able to map from Windows any network
    drive (unix accounts) due to they have not access to their share drive.

    It ask me for login and password, BUT earliear it never asked me for my windows login and password . It’s been working till the end of the year 2006.

    Please suggest solutions—–

    Many thanks in Advance


  • Niels Dettenbach Sep 14, 2010 @ 14:30

    just a small addition –

    on Gentoo Linux just do a:

    qlist -I

    cat /var/lib/portage/world

    on CentOS or other “yum”-based systems:

    yum list installed

  • john Sep 7, 2011 @ 11:40

    how to see the programs and features in redhat linux (e.g– in windows we can check the same through control panel–progrmas)

  • Niels Dettenbach Sep 7, 2011 @ 14:02

    @john: On RedHat – which is a rpm package management based distribution – you should can use i.e.:

    rpm -qa

    to list all installed packages or

    rpm -qi

    to get out details about the installed package.


    Niels Dettenbach
    Syndicat – IT & Internet

  • mahen Mar 21, 2012 @ 11:21

    how do i verify packages that are installed without using rpm, i mean recently i installed squid using make, make all, configure configure-install

    after this, how do I check this package is installed?

    • Niels Dettenbach Mar 21, 2012 @ 11:35

      …this is not possible as installing “by hand” (make install) has nothing to do with a “package” nor package management.

      To find out if i.e. squid was installed just try to locate the squid binary by where, locate or find, even if you build and install software from sources by make.

      If you use a port management system from i.e. pkgsrc, getoo portage or even FreeBSD the port management counts each modified and installed file of a port to make it possible to see which file belongs to which port (package) or which are installed etc.

      this might be another story.

  • rifu May 6, 2013 @ 14:52

    Thank you very much, I have another issue, I have Installed texlive but I still get an error message in my crm ” pdf latex not installed”, so do you know how check if any software is installed or not ? It’s different from packages, isn’t it ?

    Thank you

  • Ken Williams Apr 11, 2014 @ 15:38

    If you have a list of packages you want to query, it’s much easier to just list them instead of using grep:

    rpm -q automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel

  • Brendan Long Jul 1, 2014 @ 19:13

    Why such a complicated command for rpm-based systems? On my machine (Fedora 20), I can just run rpm -q ${package_name}, and it’s *much* faster since it doesn’t need to list every package on the system and then grep through it:

    [blong@blong-desktop tmp]$ rpm -q vala; echo $?
    [blong@blong-desktop tmp]$ rpm -q missing-package; echo $?
    package missing-package is not installed

    Is this a new feature?

  • Eric Sebasta Oct 11, 2015 @ 15:17

    In Debian based distros like Ubuntu, you can find out if a package is installed with:

    apacheInstalled=$(dpkg -s apache2 | grep ‘Status: install ok installed’| wc -l)
    #change apache2 to the package you are checking for. returns 1 if installed, 0 otherwise.
    #script does not have to be running as root… but to change installed stuff… it would.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum