Software & OS

How to Check if a Program Is Installed (Windows, macOS, Linux)

To check if a program is installed, ask the system's package list or look the command up on your PATH. On Windows run winget list "name", on macOS run brew list or open the Applications folder, and on Linux run command -v name or query the package manager.

Two different questions hide behind "is it installed?". One is "does the system have a package registered under this name?", which a package manager or the installed-apps list answers. The other is "can I run this program by typing its name?", which a PATH lookup answers. The sections below cover both, per operating system, and explain why the two can disagree.

How to check if a program is installed on Windows

The quickest check is winget, the Windows Package Manager. Open Command Prompt or PowerShell and run:

winget list git

The argument is a query, and it matches as a substring of the app's name or ID. Microsoft's documentation states that winget list shows apps installed through the Windows Package Manager as well as apps installed by other means, so a program from a downloaded installer is usually found too. If nothing matches, the list comes back empty for that query.

These options narrow the search:

OptionWhat it does
--nameLimits the match to the application name
--idLimits the match to the package ID, for example Git.Git
-e, --exactUses the exact string, case-sensitive, instead of a substring
--upgrade-availableLists only installed packages that have an update
--detailsShows detailed output for each matched package

Wildcards are not supported in the query. If a program is installed but its version cannot be determined, add -u (--include-unknown) so it is not left out of the list.

To see the Windows 11 list in a window instead, open Settings, then Apps, then Installed apps. That list also holds Microsoft Store apps. If you want to remove something you find there, see how to uninstall apps on Windows and Mac.

Check whether a command exists in PowerShell

If you only care whether you can run the program, use Get-Command (alias gcm). It gets cmdlets, functions, aliases, scripts and applications, and with a bare name it also finds executables in the folders listed in $Env:PATH:

Get-Command git

Example output (the path will differ on your machine):

CommandType     Name        Version    Source
-----------     ----        -------    ------
Application     git.exe     2.47.0.1   C:\Program Files\Git\cmd\git.exe

In a script you rarely want an error when the program is missing. Suppress it and test the result:

if (Get-Command git -ErrorAction SilentlyContinue) {
    "git is available"
} else {
    "git is not on PATH"
}

Add -All to list every command with that name, in the order PowerShell would run them. That is useful when two versions of the same tool are installed and you want to know which one wins.

How to check if a program is installed on macOS

On macOS, most graphical apps live in the /Applications folder, so open it in Finder and look. For software installed with Homebrew, ask Homebrew:

brew list

That lists all installed formulae and casks. Pass a name and Homebrew summarises that package's files, or reports an error if it is not installed:

brew list git

Two flags separate the kinds of package. --formula limits the output to formulae (command-line software) and --cask limits it to casks (graphical apps):

brew list --formula
brew list --cask

Add --versions to print the installed version of each formula. Homebrew's manual describes that flag for formulae only, so for a cask, read the version from the app itself. Homebrew only knows about software it installed. An app you dragged into /Applications from a disk image will not appear in brew list, even though it is installed. The Homebrew basics guide covers the rest of the commands.

For command-line tools, the shell lookup in the next section works on macOS too, since the default shells are POSIX-style.

How to check if a program is installed on Linux

Check the command with command -v

The portable shell check is command -v. POSIX defines it to report how the shell would resolve a name, such as the pathname of a utility, without running it. If the name cannot be found, it writes nothing to standard output and returns a nonzero exit status:

command -v python3

Example output when found:

/usr/bin/python3

This form is the one to use in scripts, because the exit status drives the logic and nothing is printed on failure:

if command -v docker > /dev/null; then
    echo "docker is on PATH"
else
    echo "docker is not installed or not on PATH"
fi

Ask the package manager on Debian and Ubuntu

On Debian-based systems, dpkg-query reads the package database. With -W (--show) it prints the name and installed version separated by a tab:

dpkg-query -W git

Example output:

git	1:2.43.0-1ubuntu7

You can choose the fields with -f (--showformat). The virtual field db:Status-Abbrev prints a three-character status such as ii , where the first i is the desired state (install) and the second is the actual state (installed):

dpkg-query -W -f='${db:Status-Abbrev} ${Package} ${Version}\n' git

The manual page documents exit status 1 when a package or file was not found and 2 for a fatal error such as invalid usage. A package that was removed but not purged can still be known to dpkg, so read the status column instead of trusting a printed name. The longer dpkg -l listing has the same status columns, but the manual notes its output is not easily machine-readable.

Ask the package manager on Fedora, RHEL and openSUSE

On RPM-based systems, rpm -q queries an installed package by name:

rpm -q git

The manual describes the argument as an "installed package named PACKAGE_NAME", and says the exit status is 0 on success and nonzero otherwise. In practice that means you can use it directly in a test, the same way as command -v. Check the exact wording of the "not installed" message on your own system, because the manual page does not quote it.

The related guide APT vs DNF compares the two package managers if you are not sure which one your distribution uses.

Why a program can be installed but not found

The two kinds of check measure different things, and the gap between them explains most confusing results.

  • Not on PATH. A command lookup searches only the folders on PATH. A program installed to its own folder, such as an unpacked archive or a portable app, is installed but invisible to command -v and Get-Command. Run it by its full path or add its folder to PATH.
  • A new terminal is needed. The installer may have updated PATH, but a terminal that was already open keeps the old value. Close it and open a new one before concluding the install failed.
  • Graphical apps have no command. Many desktop apps never put an executable on PATH. Look in the installed-apps list or the package manager instead.
  • Different package managers. A program installed with winget will not show in brew list, and one installed from a .deb file shows in dpkg-query but may be missing from a Snap or Flatpak list. Check the manager that actually installed it.
  • Two copies. If two versions are installed, the lookup reports the first one on PATH. On Windows, Get-Command name -All shows every match in run order.

Check the version once you know it is there

Finding the program is usually the first half of the job. Most command-line tools print their version with --version, for example git --version, though a few use -v, -V or a version subcommand. The package manager checks above also print the version, so a single winget list, brew list --versions or dpkg-query -W answers both questions at once.

If the check gives a confusing answer

Run both kinds of check and compare. If the package manager says the program is installed but the command lookup finds nothing, the problem is PATH, not the installation. If the command lookup finds a path but the package manager does not know the package, the program came from somewhere else, such as a manual download, a language-specific installer like pip or npm, or a bundled copy inside another application. The path that command -v or Get-Command prints usually tells you which of these it is.

Frequently asked questions

Why does winget list show a program that I installed by hand?
Microsoft's documentation says winget list shows apps installed through the Windows Package Manager as well as apps installed by other means. So a program from a downloaded installer can appear in the list, though its package ID may be blank or unknown to winget.
A program is installed but the command is not found. Why?
A command lookup only searches the folders on your PATH. A program can be installed in a folder that is not on PATH, or be a graphical app with no command at all. In that case, check the package manager or the list of installed apps instead of the command lookup.
How do I check the installed version as well?
Most command-line tools accept a flag such as --version. Package managers also report it: winget list shows a Version column, brew list --versions prints the version for formulae, and dpkg-query -W prints the name and installed version separated by a tab.
Can I use these checks in a script?
Yes. In a POSIX shell, command -v prints nothing and returns a nonzero exit status when the name is not found, and dpkg-query returns exit status 1 when no package matches. In PowerShell, add -ErrorAction SilentlyContinue to Get-Command and test the result in an if statement.

Sources