Linux Guide

How to Check If Software Is Installed on Linux

The command that answers the question in under a millisecond, the package queries that confirm it, and the cases in which both return a misleading result.

By Oyekale OlawaleUpdated November 20268 min read

Quick Answer

Run command -v name. A printed path means the program is installed and reachable from PATH. No output means the program is missing or sits outside PATH.

To query the package database, use dpkg -s name on Debian and Ubuntu, rpm -q name on Fedora and RHEL, or pacman -Q name on Arch. Snap and Flatpak applications are recorded separately and need snap list and flatpak list.

How I Tested These Commands

I ran the Debian-family commands in an Ubuntu 24.04.5 container and recorded the output, the exit status and the run time of each one. Every timing is the average of 50 runs and includes shell start-up.

The container has no Snap, Flatpak, Fedora or Arch tooling. Commands for those systems follow the official manual pages and were not run here. Code blocks for them carry the label “illustrative output”.

Two results changed how I write these checks. First, apt list --installed exits with code 0 even when the package is absent, so it cannot drive an if statement. Second, a wildcard query with dpkg -l returned 38 lines marked ii (installed) and 28 marked un (known to dpkg, not installed), which means an unanchored grep reports packages that are not on the machine.

Method Comparison Matrix

The table separates checks that look at PATH from checks that read a package database. The two groups answer different questions, and a complete answer often needs one of each.

Advertisement
MethodWorks onWhat it checksRun in test
command -v nameAny POSIX shellPATH lookupYes
which nameMost systems; absent from some minimal imagesPATH lookupYes
type -a nameBash, ZshPATH, aliases and functionsYes
dpkg -s nameDebian, Ubuntu, MintPackage databaseYes
rpm -q nameFedora, RHEL family, SUSEPackage databaseNo
pacman -Q nameArch, ManjaroPackage databaseNo
snap list nameSystems with snapdSnap registryNo
flatpak info idSystems with FlatpakFlatpak registryNo
find or locateAll distributionsFile names on diskYes (find)

Every check finished in under 16 ms, so speed rarely decides the choice. Accuracy matters more. The absolute values depend on hardware, and the ordering is the useful part: builtins are fastest, dpkg comes next and apt is slowest because it loads more data.

Method 1: Look Up the Command With command -v

The builtin command -v searches PATH and prints the location of the first match. POSIX defines it, so it works in Bash, Zsh and dash without any extra package.

Terminal (Bash, tested)
$ command -v git
/usr/bin/git

$ command -v nonexistent_tool
$ echo $?
1

The exit status of a missing command depends on the shell. Bash returns 1 and dash returns 127. A script should therefore test for success or failure and avoid a comparison with one fixed number.

The command which git gives the same path but is an external program, and the Ubuntu container rejected which --version as an illegal option. Some minimal container images omit it. When two copies of a program compete, type -a python3 lists every match, including aliases and shell functions. On the test system it printed /usr/bin/python3 and /bin/python3, two paths to one file because /bin links to /usr/bin.

A third command, whereis git, searches a fixed set of system directories instead of PATH and also reports manual pages.

Strengths

  • Builtin, with nothing to install
  • Average of 0.7 ms per call
  • Prints the exact path
  • Safe to use in scripts

Limits

  • Sees only directories listed in PATH
  • Reports no version or package name
  • Uses the PATH of the current shell

Method 2: Query the Package Database

A package manager records every package it installs. A query against that record confirms the installation state even when the program has no file in PATH, as with libraries and background services.

Debian, Ubuntu and Linux Mint

The tool dpkg reads the local database and does not need network access. The query dpkg -s prints the status of one package, and dpkg-query -W -f returns only the fields that a script needs.

Ubuntu 24.04 terminal (tested)
$ dpkg -s git | head -n 2
Package: git
Status: install ok installed

$ dpkg-query -W -f='${Status}\n' git
install ok installed

$ dpkg -s nginx
dpkg-query: package 'nginx' is not installed and no information is available

All three forms exit with status 1 when the package is absent. The first column of dpkg -l shows the state of each package. The code ii means installed, and rc means removed with configuration files left on disk. Anchor any search with dpkg -l | grep '^ii' to exclude entries in other states.

The apt front end offers apt list --installed git, which prints a line such as git/now 1:2.43.0-1ubuntu7.4 amd64 [installed,local]. For a missing package it prints only the Listing... header and still exits with 0. It also warns that apt has no stable command-line interface. Use dpkg -s in scripts and keep apt list for reading by eye.

Advertisement

The reverse lookup works as well. The query dpkg -S /usr/bin/git prints git: /usr/bin/git, which names the package that owns a file. That is the quickest way to find the package behind a command when the two names differ.

Fedora, RHEL, Rocky Linux, AlmaLinux and openSUSE

On RPM-based systems, rpm -q reads the local RPM database. Package names are case-sensitive here, so rpm -q Git finds nothing.

Fedora terminal (illustrative output)
$ rpm -q bash
bash-5.2.32-1.fc41.x86_64

$ rpm -q git
package git is not installed

$ dnf list --installed 'nginx*'
$ rpm -qf /usr/bin/ssh   # package that owns a file

RHEL 8 and later use dnf, and yum remains as an alias. Fedora 41 introduced DNF 5, and dnf list --installed runs on both versions. On openSUSE, zypper se -i --match-exact name performs the same check, and rpm -q also works.

Arch Linux and Manjaro

The option -Q queries the local database, so no network is needed.

Arch terminal (illustrative output)
$ pacman -Q firefox
firefox 131.0-1

$ pacman -Q vim
error: package 'vim' was not found

$ pacman -Qs python   # search names and descriptions
$ pacman -Qo /usr/bin/git   # package that owns a file

The search form -Qs matches regular expressions against names and descriptions, so a short term returns related packages along with the exact one. Packages built from the AUR appear in the output as well, because pacman installs them. The command pacman -Qm lists only those foreign packages.

Method 3: Check Snap, Flatpak and AppImage Separately

Snap and Flatpak keep their own registries. A program installed through either one is invisible to dpkg and rpm.

Terminal (illustrative output)
$ snap list vlc
$ flatpak list --app | grep -i gimp
$ flatpak info org.gimp.GIMP

Snap places launchers in /snap/bin, a directory that is normally in PATH. For that reason command -v vlc usually finds a Snap-installed program while dpkg -s vlc does not. Flatpak behaves differently. An application starts with flatpak run org.gimp.GIMP, and the launcher carries the application ID, so command -v gimp returns nothing.

An AppImage is a single executable file with no registry. Search the folders where downloads are kept, for example with find ~ -iname '*.AppImage'.

Method 4: Use the Graphical Software Manager

GNOME Software and KDE Discover list installed applications in an Installed view, and Synaptic provides a status filter for installed packages. These lists mainly cover applications with desktop entries. Command-line utilities and libraries often do not appear, so a terminal check remains necessary for them.

Method 5: Search the File System and Language Tools

Software that was compiled from source or copied into a directory has no database entry. The command find searches by file name, and its run time grows with the size of the file system. Limit it to likely locations.

Terminal (find tested)
$ find /usr /opt "$HOME" -name ffmpeg -type f 2>/dev/null
$ sudo updatedb && locate ffmpeg   # needs plocate or mlocate

The locate command reads a prebuilt index and returns at once, but the index is only as current as the last updatedb run. The test container had no locate package, so I did not time it.

Advertisement

Language package managers keep their own lists. In the test, pip show requests printed the name and version, and pip show for an absent package printed “WARNING: Package(s) not found”. The command npm ls -g --depth=0 lists global Node packages.

Version managers need extra care. The tool nvm is a shell function loaded by ~/.bashrc, so it does not exist in a non-interactive script unless the script sources nvm.sh first. Run nvm ls in an interactive shell, or pyenv versions for Python.

Which Check Should You Run?

The flow below starts with the cheapest check and moves to the package database only when PATH gives no answer.

Decision flow for checking whether software is installed on Linux Start with command -v. If a path prints, the program is installed. If not, choose dpkg -s on Debian and Ubuntu, rpm -q on Fedora and RHEL, or pacman -Q on Arch. If the package is still not found, check snap list and flatpak list, then search with find or locate. Is the program installed? command -v name Is a path printed? Yes Installed on PATH No Which distribution family? dpkg -s name Debian, Ubuntu rpm -q name Fedora, RHEL pacman -Q name Arch, Manjaro Package still not found? snap list | flatpak list then search with find or locate

Which Check Sees Which Installation Type

No single command covers every way of installing software. The matrix shows where each kind of installation is recorded.

Installed throughcommand -vPackage querysnap listflatpak listfind
apt, dnf or pacmanYes (programs)YesNoNoYes
SnapUsuallyNoYesNoYes
FlatpakNoNoNoYesYes
AppImageIf in PATHNoNoNoYes
Source build in /usr/localYesNoNoNoYes
nvm or pyenvWhen loadedNoNoNoYes

Distribution Command Reference

Use this table once the distribution is known. The file-owner column answers the common question of which package supplied a given command.

DistributionCheck one packageList all installedOwner of a file
Debian, Ubuntu, Mintdpkg -s namedpkg-query -Wdpkg -S /path
Fedorarpm -q namednf list --installedrpm -qf /path
RHEL, Rocky, AlmaLinux, CentOS Streamrpm -q namerpm -qarpm -qf /path
openSUSErpm -q namezypper se -irpm -qf /path
Arch, Manjaropacman -Q namepacman -Qpacman -Qo /path
Alpineapk info -e nameapk infoapk info -W /path
Gentooqlist -I nameqlist -Iqfile /path
Snapsnap list namesnap listNot applicable
Flatpakflatpak info idflatpak list --appNot applicable

Only the Debian row was run in the test container. The Gentoo commands come from the portage-utils package.

Managing More Than One Server?

A shell check covers one machine at a time. Teams with many hosts can compare open-source monitoring platforms for cost, mapping and alerting.

Compare Open-Source Monitoring Tools

Four Cases and the Correct Check

Case 1: A server owner says Docker is installed

Run command -v docker first. A path settles the question, and docker --version then prints the version. When the command prints nothing, query the package names that provide it. Debian-family systems use docker.io or docker-ce, so check both with dpkg -s, and run snap list docker in case the owner used Snap.

Case 2: The command exists but the package name is unknown

The package and the command often have different names. The program dig comes from bind-utils on RHEL-family systems and from bind9-dnsutils on current Debian and Ubuntu releases. Resolve the path with command -v and pass it to the owner query, for example rpm -qf "$(command -v dig)" or dpkg -S "$(command -v dig)".

Case 3: A package was removed but its settings remain

The entry rc in dpkg -l means the program files are gone and the configuration files are still on disk. Running sudo apt purge nginx removes those files. The program itself is not running in this state, and a service that still answers has a different cause.

Case 4: A tool works for you and fails under sudo

The PATH that sudo uses comes from the secure_path setting in sudoers. A tool in ~/.local/bin is visible to your shell and invisible to sudo. Compare the two with sudo sh -c 'command -v toolname'. Cron jobs behave in a similar way because cron starts with a short default PATH.

Advertisement

AI Coding Tools and Environment Checks

Terminal-based coding agents are installed as command-line programs. The comparisons of open source Claude Code alternatives and Claude Code against Cowork cover how they differ in use. After any such installation, command -v shows whether the new binary is on PATH and which copy runs first. The same check applies after following a setup walkthrough such as the Kimi Code guide.

Assistants can also lose track of the machine state during a long session, a limit described in the guide to the context ceiling in AI coding apps. A direct command -v or dpkg -s call returns the actual state and costs almost nothing. People who build automated workflows can add this kind of precheck as a first step, and the comparison of AI agent frameworks for simple workflows lists options for structuring such steps.

Common Mistakes

MistakeResultFix
Piping dpkg -l to an unanchored grepMatches packages in the un and rc statesUse grep '^ii' or dpkg -s
Using apt list inside an if testExit status is 0 even for a missing packageUse dpkg -s or dpkg-query -W
Searching the package database by command nameNo match, because the names differUse dpkg -S, rpm -qf or pacman -Qo
Calling nvm in a scriptError that the command is not foundSource nvm.sh in the script first
Using another distribution’s toolError that the command is not foundRead /etc/os-release to confirm the family
Comparing the exit status with one numberBash returns 1 and dash returns 127Test only for success or failure

A Script That Checks a List of Programs

A provisioning step often needs to check several programs at once. This version prints one line per program and exits with status 1 when any program is missing, so a deployment job can stop early.

check_tools.sh (tested in Bash)
#!/usr/bin/env bash
tools=(git curl wget vim node python3 docker nginx)
missing=0

for tool in "${tools[@]}"; do
    if path=$(command -v "$tool"); then
        printf 'FOUND    %-10s %s\n' "$tool" "$path"
    else
        printf 'MISSING  %-10s\n' "$tool"
        missing=$((missing + 1))
    fi
done

printf '\n%d of %d programs are missing.\n' "$missing" "${#tools[@]}"
[ "$missing" -eq 0 ]
Output in the test container
FOUND    git        /usr/bin/git
FOUND    curl       /usr/bin/curl
FOUND    wget       /usr/bin/wget
MISSING  vim
FOUND    node       /usr/bin/node
FOUND    python3    /usr/bin/python3
MISSING  docker
MISSING  nginx

3 of 8 programs are missing.

Save the file, run chmod +x check_tools.sh and start it with ./check_tools.sh. Replace the list with the programs that your project needs.

Cannot Install Software on This Machine?

On a locked-down work computer, some tasks can run in the browser. This roundup covers free web tools such as Excalidraw and Photopea.

See Free Browser-Based Tools

FAQ

What is the fastest way to check if a program is installed on Linux?

Run command -v programname. It is a shell builtin that averaged 0.7 ms in my test and prints the path of the program, or nothing when PATH has no match.

How do I check without knowing the exact package name?

Search the package list with a keyword. On Debian and Ubuntu use dpkg -l | grep '^ii' | grep -i keyword. On Fedora and RHEL use rpm -qa | grep -i keyword. On Arch use pacman -Qs keyword.

Why does command -v find nothing for a program that runs?

The program may start through a full path, a Flatpak application ID or a version manager that loads only in interactive shells. The shell may also have a different PATH from the one used to launch the program. Print the current value with echo "$PATH".

Do I need root access to check installed software?

No. The commands command -v, dpkg -s, rpm -q and pacman -Q only read data and run as a normal user. A search with find / may print permission errors, and updatedb needs root.

How do I find the version of an installed program?

Run the program with --version, for example git --version. The package database also reports it: dpkg-query -W git on Debian and Ubuntu, rpm -q git on Fedora and RHEL, and pacman -Q git on Arch.

How do I list everything that is installed?

Use dpkg-query -W on Debian and Ubuntu, rpm -qa on RPM-based systems and pacman -Q on Arch. Add snap list and flatpak list for those formats.

Advertisement

Conclusion

Start with command -v name, because it is fast, available in every POSIX shell and safe in scripts. Move to dpkg -s, rpm -q or pacman -Q when the question concerns the package itself, such as its version or its state after removal.

Check Snap and Flatpak separately, and use find for software that no package manager recorded. Match the command to the installation method, since each method leaves a record in a different place.

Get Notified When New Reviews & Updates are Published

We don’t spam! Read our privacy policy for more info.