command not found
This error occurs when the shell cannot find the executable binary matching the command name in your system's PATH directories.
Usually happens because:
- ☑ The program package is not installed on the server
- ☑ Program bin directory is not listed in active $PATH
- ☑ Spelling typo inside command invocation
🔍 Quick Checklist:
What is command not found?
When you type a command in the terminal, the shell (such as bash or zsh) looks through a list of directories specified in the $PATH environment variable to locate the matching executable binary file. If the binary is not installed, the folder is missing from the $PATH list, or the command name has a spelling typo, the shell returns 'command not found'.
Common Causes
- Binary program not installed: The software package hosting the executable is not installed on the system.
- Missing path in $PATH variable: The program is installed, but its directory is not listed inside your environment's $PATH variable (common for custom scripts or user installations).
- Spelling typo in command name: Typing errors in command invocation.
| Cause | Frequency |
|---|---|
| Target binary package not installed on system | ⭐⭐⭐⭐⭐ |
| Directory not added to environment $PATH variable | ⭐⭐⭐⭐ |
| Spelling typo in command name | ⭐⭐⭐ |
Common Mistakes
- Forgetting to run `source ~/.bashrc` or restart the terminal window after updating your PATH variable, which leaves the old PATH profile active.
- Typing a command inside a new shell that does not support it (e.g. using `ll` command in environments that lack an alias mapping for `ls -la`).
How to Fix
Linux Operations & Verification
Append custom bin directories to your user's shell configuration variables profile to enable global access.
# 1. Append target export to shell configuration
$ echo 'export PATH="$PATH:/usr/local/bin/custom"' >> ~/.bashrc
# 2. Reload shell configuration properties
$ source ~/.bashrc
# 3. Test command executionPlatform Specific Fixes
Install target package using standard Debian utility helper apt.
sudo apt update
sudo apt install git -yBest Practices
- Verify binary availability using the `which` or `type` command (e.g. `which git` will print the path if installed).
- Document application binary dependencies inside project README files.
Frequently Asked Questions (FAQ)
Q: What is the PATH variable?
The PATH variable is a colon-separated list of directories ($PATH) that the shell searches when you execute a command.
Q: How do I print my active PATH?
Run 'echo $PATH' in your shell to inspect all search directories.
Q: Why does it fail on script executions inside my current directory?
For security reasons, Linux shells do not search the current directory (.) by default. To run a script in the active directory, prepend './' (e.g. './myscript.sh').
Q: How do I permanently add a folder to my PATH?
Add 'export PATH="$PATH:/path/to/folder"' to your ~/.bashrc or ~/.zshrc file, then run 'source ~/.bashrc' to reload.