✓ The fix that resolves 90% of "command not found / permission denied / no such file" errors
When a Linux command fails, the cause is almost always one of three things: the binary isn't on $PATH, the file lacks execute permission, or the path is wrong. This one diagnostic resolves all three in a single pass:
# Diagnose any failing command in one shot which <command> || echo "not on PATH — install or add the dir" ls -l $(which <command> 2>/dev/null) 2>/dev/null || true file <command> 2>/dev/null || echo "path does not resolve"
Why it works:
which checks $PATH, ls -l reveals the permission bits (the x flag is what makes a file runnable), and file confirms the path resolves to a real executable. Run these three and you know exactly which of the three causes you have — then the fix is one of: export PATH=$PATH:/path/to/dir, chmod +x <command>, or correct the path.Common errors → the fix
| Error you see | What it means | The fix |
|---|---|---|
command not found | binary not on $PATH | export PATH=$PATH:/path/to/dir |
Permission denied | missing execute bit | chmod +x <file> |
No such file or directory | wrong path / not installed | find / -name "<file>" 2>/dev/null |
Bad interpreter | shebang points to missing binary | fix line 1: #!/usr/bin/env python3 |
Segmentation fault | binary crashed (arch mismatch / bug) | file <binary> to check arch |
Address already in use | port is taken | lsof -i :<port> then kill or change |
ModuleNotFoundError | python package missing | pip install <module> |
Could not resolve host | DNS failure | check /etc/resolv.conf |