Linux 'command not found': Install the Package or Fix PATH
This error matches known, documented patterns with reliable solutions.
Quick Fix (Most Common Solution)
- Try installing the command directly by its name (works for many common tools)
- If the package name is unknown, search the package manager for the keyword
Seeing "command not found"? This error can be frustrating, but it's usually fixable. It typically affects your development workflow or system. Below you'll find clear, step-by-step solutions to resolve this issue.
What This Error Means
The shell searched all directories in the PATH environment variable and could not find an executable with that name. Either the package containing the command is not installed, or the binary is in a directory that is not in PATH.
Frequently documented in developer and vendor support forums.
Not affiliated with browser, OS, or device manufacturers.
New here? Learn why exact error messages matter →
Common Causes
- Package is not installed on this system
- Binary is installed but its parent directory is not listed in PATH
- Command name differs between distributions (e.g. python vs python3, vi vs vim)
How to Fix
- Try installing the command directly by its name (works for many common tools)
- If the package name is unknown, search the package manager for the keyword
- If installed but not found, use which to locate the binary and fix PATH
- Add the binary directory to PATH permanently in your shell profile
Last reviewed: June 2026 How we review solutions
Didn't fix it? Get a personalised solution
Environment-Specific Commands
Debian / Ubuntu — apt
sudo apt updatesudo apt install [command-name][command-name] --version
RHEL / CentOS / Fedora — dnf
sudo dnf install [command-name][command-name] --version
Fix PATH — add directory permanently
which [command]echo 'export PATH="$PATH:/path/to/directory"' >> ~/.bashrcsource ~/.bashrc[command-name] --version
Quick Diagnostic Path
- If which [command] returns a path but shell still says not found → Open a new terminal — the PATH change may not have been loaded in the current session
- If Command works as root but not as your user → The binary is in /sbin or /usr/sbin which is in root's PATH but not the user PATH. Add /usr/sbin to your PATH.
- If Command exists on another machine but not this one → Check the distro-specific package name: apt-cache search [keyword] or dnf search [keyword]
If This Still Fails, Check
- snap/flatpak installs use different paths not in default PATH — check with 'snap list' or 'flatpak list' if the command was installed that way
- Python on Ubuntu 20.04+: 'python' is not installed by default, only 'python3'. Install the alias: sudo apt install python-is-python3
- Scripts with #!/usr/bin/env python shebang will fail if only python3 is installed. Update the shebang line to #!/usr/bin/env python3
Diagnose and fix command not found
# Step 1: check if the binary exists anywhere
which [command]
find /usr /usr/local /opt -name "[command]" 2>/dev/null
# Step 2: install it (Ubuntu/Debian)
sudo apt update && sudo apt install [command]
# Step 3: if found but PATH is wrong
echo 'export PATH="$PATH:/path/to/bin"' >> ~/.bashrc
source ~/.bashrc
# Step 4: verify
which [command]
[command] --versionOS-Specific Behavior
Command Not Found Differences Across Ubuntu, CentOS, Alpine, and Debian
Command Not Found behavior varies significantly across Linux distributions because package names, default configurations, filesystem layouts, and init systems differ between distros. A fix that works on Ubuntu may fail on CentOS or Alpine.
Package name differences are the most common trap: the OpenSSL development library is libssl-dev on Debian/Ubuntu but openssl-devel on RHEL/CentOS. Python 3 is python3 on Debian/Ubuntu but may be python3.x on older RHEL. Alpine Linux uses musl libc instead of glibc, which causes binary compatibility issues with pre-compiled binaries and Python native extensions that assume glibc. Init system differences: Ubuntu 16.04+ uses systemd, older CentOS uses SysVinit, Alpine uses OpenRC — systemctl commands fail on Alpine. When documenting fixes, always specify which distribution and version the fix was tested on. Use cat /etc/os-release to identify the exact distro and version before applying fixes from Stack Overflow or documentation.Optional follow-up
Some users ask whether saving fixes for recurring errors would be useful when the same issue appears again.
Was this explanation helpful?
Frequently Asked Questions
How do I find the correct package name for a command?
On Debian/Ubuntu: 'apt-cache search [keyword]'. On RHEL/Fedora: 'dnf provides [command]'. The apt-file tool also maps command names to packages: apt-file search [command].
I installed the package but the command is still not found
The binary may be in /usr/local/bin or another directory not in PATH. Run 'find /usr /opt -name [command] 2>/dev/null' to locate it, then add that directory to PATH.
What is PATH and how do I check it?
PATH is a colon-separated list of directories the shell searches for executables. Run 'echo $PATH' to see it. Run 'which [command]' to see which PATH directory contains a command.
Related Resources
Also Known As
- Linux error
- Unix error
- Terminal error
- Shell error
- Command line error
Common Search Variations
- "linux terminal error"
- "permission denied linux fix"
- "command not found linux"
- "linux shell error solution"
- "ubuntu error how to fix"
- "linux process crashed"
Related Errors
Still Stuck?
Paste a different error message or upload a screenshot to get help instantly.