Sometimes, we need to know whether or not some packages are being installed on the system. And the command which will let us find out the answer is different from one distro to another. So, we will see how to do it on the most popular distros.
Suppose you want to find out package coreutils or shred is installed or not.
On the distros that use the tool APT to manage their packages, like Debian and its based distros: (such as: Ubuntu / Linux Mint / Elementary OS / Linux Lite / deepin / antiX / Zorin OS / LXLE / Peppermint OS / SparkyLinux)
To list all the installed packages with dpkg:
$ dpkg --list | lessTo query whether or not coreutils is installed:
$ dpkg --status 'coreutils'or, use wildcards:
$ dpkg --status 'core*'To search for a filename from the installed packages, for example shred is part of the coreutils package:
$ dpkg --search 'shred'To see whether or not shred or coreutils is installed:
$ dpkg --list shred coreutilsOr, the grep way:
$ dpkg --list | grep -iE 'shred|coreutils'See the manual:
$ man dpkgOr read it online: dpkg(1)
On distros that use the tool RPM to manage their packages: (like: red hat / SUSE / openSUSE / CentOS / Fedora / Mageia / Scientific Linux / Korora Project)
To list all the installed packages with rpm:
$ rpm -qa | lessTo check whether coreutils is installed or not:
$ rpm -qa 'coreutils'or, use wildcards:
$ rpm -qa 'core*'To see whether or not shred or coreutils is installed:
$ rpm -qa shred coreutilsOr, the grep way:
$ rpm -qa | grep -iE 'shred|coreutils'See the manual:
$ man rpmOr read it online: rpm(8)
On distros that use the tool PACMAN to manage their packages: (like: Arch Linux / Manjaro Linux / Antergos / KaOS / ArchBang Linux / BlackArch Linux / Parabola GNU/Linux-libre / Chakra GNU/Linux)
To list all the installed packages with pacman:
$ pacman -Q | lessTo check whether coreutils is installed or not:
$ pacman -Qs coreutilsTo see whether or not shred or coreutils is installed:
$ pacman -Qs shred coreutilsOr, the grep way:
$ pacman -Qs | grep -iE 'shred|coreutils'See the manual:
$ man pacmanOr read it online: pacman(8)
On distros that use the tool Gentoo to manage their packages: (like: Sabayon / CoreOS / Calculate Linux)
To list all the installed packages with ls & cut:
$ ls -d /var/db/pkg/*/*| cut -f5- -d/ | lessTo display all packages you directly installed:
$ cat /var/lib/portage/world | lessTo check whether coreutils is installed or not:
$ ls -d /var/db/pkg/*/*| cut -f5- -d/ | grep -i 'coreutils'To see whether or not shred or coreutils is installed:
$ ls -d /var/db/pkg/*/*| cut -f5- -d/ | grep -iE 'shred|coreutils'Onย BSD based systems (e.g:ย FreeBSDย /ย GhostBSDย /ย DragonFly BSD)
For FreeBSD >= 10.x:
To list all the installed packages with pkg:
$ pkg info | lessTo search for a filename from the installed packages, for example gshred is part of the coreutils package:
$ pkg which `which gshred`To check whether coreutils is installed or not:
$ pkg info -x coreutilsor, use wildcards:
$ pkg info -x 'core*'To see whether or not shred or coreutils is installed:
$ pkg info | grep -iE 'gshred|coreutils'See the manual:
$ man pkgOr read it online: pkg(8)
For FreeBSD < 10.x:
To list all the installed packages with pkg_info:
$ pkg_info | lessTo search for a filename from the installed packages, for example gshred is part of the coreutils package:
$ pkg_which `which gshred`To check whether coreutils is installed or not:
$ pkg_info -x coreutilsor, use wildcards:
$ pkg_info -x 'core*'To see whether or not shred or coreutils is installed:
$ pkg_info | grep -iE 'gshred|coreutils'See the manual:
$ man pkg_infoOr read it online: pkg_info(1)
On MacOSX:
To list all the installed packages with port:
$ port installed | lessTo check whether coreutils is installed or not:
$ port installed coreutilsTo see whether or not shred or coreutils is installed:
$ port installed shred coreutilsOr, the grep way:
$ port installed | grep -iE 'shred|coreutils'See the manual:
$ man portOr read it online: port(1)
