Fix "command not found" on Linux
command not foundNo such file or directorynot in PATH"command not found" means the shell couldn't locate that program. Either it isn't installed, or it is but isn't on your PATH. Here is how to tell which and fix it.
Is it installed at all?
Search for the binary. If which finds nothing but the file exists somewhere, it's a PATH problem; if it's nowhere, install it:
which toolname
ls /usr/bin/toolname /usr/local/bin/toolname 2>/dev/null
Install it
# Debian/Ubuntu
apt install package
# RHEL/Alma/Rocky
dnf install package
Installed but "not found"? Fix your PATH
If the binary exists but the shell can't see it, its folder isn't on PATH. Add it (and persist it in your shell profile):
export PATH=":/usr/local/bin"
# make it permanent: add that line to ~/.bashrc
If /usr/local/bin/toolname works but toolname alone doesn't, it's definitely PATH — not a missing install.
Not found = not installed, or not on PATH. which/ls to tell which, then install the package or add its folder to PATH.
Cause: wrong package name for your distro
The command and its package aren't always named the same, and package names differ between distro families. If the install command fails with "no package found", search for the actual package name — for example the netstat command comes from the net-tools package on many distros.
Cause: an alias or function only exists in your interactive shell
If a command works in your interactive login shell but not in a script or cron job, it may actually be a shell alias or function defined in your shell profile, which non-interactive shells don't load. Scripts should call the real binary, not rely on aliases.
How to prevent "command not found" issues
- Install tools via your distro's package manager rather than ad-hoc downloads, so PATH is set up automatically.
- Keep a documented list of custom tools and where they live for a new admin joining the server.
- Avoid relying on shell aliases inside scripts or cron jobs.
- Use full paths in automation (cron, systemd units) rather than assuming PATH.
Related errors
If the command exists but you get denied running it, that's permission denied on Linux, a different problem. New to server administration? Start with essential Linux commands or connecting with SSH first.
A clean VDS to work on
Our VDS plans give you full root to install whatever you need, on protected NVMe in Frankfurt.
Frequently asked questions
What does "command not found" mean on Linux?
The shell couldn't find that command in any folder on your PATH. Either the program isn't installed, or it is but its directory isn't on your PATH.
How do I know if it's installed or just not on PATH?
Run which toolname and look for the binary with ls in common bin folders. If the file exists but which doesn't find it, it's a PATH issue; if it doesn't exist, install the package.
How do I add something to my PATH permanently?
Add export PATH="$PATH:/your/dir" to your ~/.bashrc (or ~/.profile), then reload it. That makes the directory available in every new shell session.
Why does a command work when I type it directly but not in a cron job?
Cron runs with a minimal PATH and no interactive shell config, so aliases and PATH additions from your profile don't apply. Use the command's full path in cron — see our cron job troubleshooting guide.
How do I find which package provides a missing command?
On Debian/Ubuntu, apt-file search can find it (after installing apt-file). On RHEL/AlmaLinux/Rocky, dnf provides can do the same. Search engines work fine too for well-known tools.
Is it safe to just copy a binary into /usr/local/bin?
For a single trusted, self-contained binary, yes — that's a normal way to install standalone tools. Avoid it for anything with dependencies or that needs regular updates; use the package manager for those instead.
Related articles
Fix SSH "Connection refused" / "Connection timed out"
SSH "connection refused" vs "timed out" — what each means and the exact steps to fix them.
Read fix Linux & VPSFix "Permission denied" on Linux (chmod & chown Explained)
"Permission denied" on a script or file? Understand chmod/chown and fix it the right way.
Read fix Linux & VPSHow to Check CPU, RAM & Disk Usage on a Linux Server
The essential commands to check CPU, RAM and disk on Linux — and find what's eating them.
Read fix