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.
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.
| Method | Works on | What it checks | Run in test |
|---|---|---|---|
command -v name | Any POSIX shell | PATH lookup | Yes |
which name | Most systems; absent from some minimal images | PATH lookup | Yes |
type -a name | Bash, Zsh | PATH, aliases and functions | Yes |
dpkg -s name | Debian, Ubuntu, Mint | Package database | Yes |
rpm -q name | Fedora, RHEL family, SUSE | Package database | No |
pacman -Q name | Arch, Manjaro | Package database | No |
snap list name | Systems with snapd | Snap registry | No |
flatpak info id | Systems with Flatpak | Flatpak registry | No |
find or locate | All distributions | File names on disk | Yes (find) |
Measured Time per Call (milliseconds)
Ubuntu 24.04.5 container, average of 50 runs, shell start-up included (baseline 0.7 ms)
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.
$ command -v git
/usr/bin/git
$ command -v nonexistent_tool
$ echo $?
1The 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.
$ 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 availableAll 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.
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.
$ 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 fileRHEL 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.
$ 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 fileThe 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.
$ snap list vlc
$ flatpak list --app | grep -i gimp
$ flatpak info org.gimp.GIMPSnap 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.
$ find /usr /opt "$HOME" -name ffmpeg -type f 2>/dev/null
$ sudo updatedb && locate ffmpeg # needs plocate or mlocateThe 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.
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.
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 through | command -v | Package query | snap list | flatpak list | find |
|---|---|---|---|---|---|
| apt, dnf or pacman | Yes (programs) | Yes | No | No | Yes |
| Snap | Usually | No | Yes | No | Yes |
| Flatpak | No | No | No | Yes | Yes |
| AppImage | If in PATH | No | No | No | Yes |
| Source build in /usr/local | Yes | No | No | No | Yes |
| nvm or pyenv | When loaded | No | No | No | Yes |
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.
| Distribution | Check one package | List all installed | Owner of a file |
|---|---|---|---|
| Debian, Ubuntu, Mint | dpkg -s name | dpkg-query -W | dpkg -S /path |
| Fedora | rpm -q name | dnf list --installed | rpm -qf /path |
| RHEL, Rocky, AlmaLinux, CentOS Stream | rpm -q name | rpm -qa | rpm -qf /path |
| openSUSE | rpm -q name | zypper se -i | rpm -qf /path |
| Arch, Manjaro | pacman -Q name | pacman -Q | pacman -Qo /path |
| Alpine | apk info -e name | apk info | apk info -W /path |
| Gentoo | qlist -I name | qlist -I | qfile /path |
| Snap | snap list name | snap list | Not applicable |
| Flatpak | flatpak info id | flatpak list --app | Not 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 ToolsFour 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.
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
| Mistake | Result | Fix |
|---|---|---|
Piping dpkg -l to an unanchored grep | Matches packages in the un and rc states | Use grep '^ii' or dpkg -s |
Using apt list inside an if test | Exit status is 0 even for a missing package | Use dpkg -s or dpkg-query -W |
| Searching the package database by command name | No match, because the names differ | Use dpkg -S, rpm -qf or pacman -Qo |
Calling nvm in a script | Error that the command is not found | Source nvm.sh in the script first |
| Using another distribution’s tool | Error that the command is not found | Read /etc/os-release to confirm the family |
| Comparing the exit status with one number | Bash returns 1 and dash returns 127 | Test 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.
#!/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 ]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 ToolsFAQ
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.
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.