Fix: command not found
bash: something: command not found means the shell could not find a program with that name in any PATH directory. The usual causes: not installed, installed outside PATH, a typo, or a stale shell.
Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?
bash: kubectl: command not found
zsh: command not found: docker
sh: 1: node: not found
/bin/sh: python: not found
The shell looked through every directory listed in your PATH variable for an executable with that name and found none. Either the program is not installed, it is installed somewhere PATH does not point, or you typed a name that differs from the real one.
Cause 1: the program is not installed
type kubectl # "not found" confirms it
apt list --installed 2>/dev/null | grep -i kubectl # Debian, Ubuntu
rpm -qa | grep -i kubectl # RHEL, Fedora
brew list | grep -i kubectl # macOS Homebrew
Install it with your package manager and try again. Sometimes the package name is not the command name: pip comes from python3-pip, ifconfig from net-tools, ss and nsenter from iproute2 and util-linux, mkpasswd from whois. On Debian and Ubuntu, apt-file search bin/ifconfig (after apt install apt-file && apt-file update) tells you which package provides a file; on Fedora use dnf provides '*/bin/ifconfig'.
Cause 2: installed, but not on PATH
Tools installed by language package managers land in directories the default PATH does not include: ~/.local/bin (pip), ~/go/bin, ~/.cargo/bin, ~/.npm-global/bin, /usr/local/go/bin, /opt/homebrew/bin on Apple Silicon Macs, or a tool-specific folder.
echo "$PATH" | tr ':' '\n' # what is searched, in order
find / -name kubectl -type f 2>/dev/null # where it actually is
# Run it once by full path
~/.local/bin/mytool --version
# Add the directory for this session
export PATH="$HOME/.local/bin:$PATH"
# Make it permanent: add that line to ~/.bashrc (bash) or ~/.zshrc (zsh), then
source ~/.bashrc
A related case: the file exists and is on PATH but is not executable (chmod +x) or has Windows line endings in its first line. Those produce Permission denied or bad interpreter instead, each covered in its own Fix article.
Cause 3: a typo or a different name
Commands are case sensitive and often not what the project is called: python may only exist as python3, Docker Compose v2 is docker compose (a space), nvim not neovim, rg for ripgrep, fd or fdfind on Debian. Tab completion is the quickest check: type the first letters and press Tab twice.
Cause 4: a shell that has not noticed a change
Bash caches command locations. If you installed, moved or deleted a binary in a terminal that is already open, run hash -r or open a new terminal. In cron, CI runners and sudo, PATH is different from your interactive shell: cron has a minimal PATH, and sudo resets PATH through secure_path. Use full paths in those contexts, or set PATH=... at the top of the crontab.
Check before you run this
- Runs with administrator rights. Make sure you understand every line.
hash -r
sudo env | grep ^PATH= # what sudo sees
sudo /usr/local/bin/mytool # full path works regardless
Check that it is fixed
command -v kubectl # prints the path and exits 0
kubectl version --client
When it is not what you think
./script.sh: line 3: foo: command not foundinside a script points at a command used by the script, not at the script itself. Often it is a function or alias that only exists in your interactive shell, or$'\r': command not found, which means CRLF line endings.sudo: mytool: command not foundwhilemytoolworks for you: sudo uses its own PATH. Use the full path orsudo -E env "PATH=$PATH" mytoolif your policy allows it.- A command that worked yesterday and is gone today usually means a version manager (nvm, pyenv, rbenv, asdf) is no longer initialized in your shell startup file, or a Python virtual environment is not activated.
Permission deniedis a different error: the file was found but cannot be executed.
Official documentation
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0049 Pipes and redirection: connecting commands A pipe sends one command's output into another command, and redirection sends output to a file. Together they let small tools build… Beginner · Explains an idea · Linux, macOS Article Basics · Text processing 15 Oct 2026
- 0050 File permissions: chmod, chown and what 755 means Every file has an owner, a group and read/write/execute permissions for three kinds of users. chmod changes the permissions and chown changes… Beginner · Explains an idea · Linux, macOS Article Basics 15 Oct 2026
- 0051 Environment variables and PATH Environment variables are named settings that every program inherits from the shell. PATH is the one that tells the shell where to… Beginner · Explains an idea · Linux, macOS Article Basics 15 Oct 2026
- 0057 Shell cheat sheet: everyday commands A quick reference for moving around, managing files, viewing and searching text, checking processes and disk space in bash and zsh, with… Beginner · Cheat sheet · Linux, macOS Article Basics · Command-line tools 15 Oct 2026
- 0099 Proxmox VE repositories and updates: enterprise vs no-subscription A fresh Proxmox VE install uses the enterprise repository, which needs a subscription. Learn how to switch to the no-subscription repository and… Beginner · Step by step · Linux Article Installation & first steps · Packages & updates 15 Oct 2026
- 0176 apt vs dnf: package commands and automatic security updates The everyday package commands on Debian/Ubuntu (apt) and RHEL/Rocky/Alma (dnf) side by side, plus how to turn on automatic security updates on… Beginner · Cheat sheet · Linux Article Packages & updates 15 Oct 2026
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Dominik +3,886 chars