What is PATH and why "command not found" is almost never what it seems
Published on 2026-09-12 by frfrand
A colon-separated list of folders that decides which program runs. How it is searched, why order matters so much, and the three cases where it fails.

Short answer: the PATH is an environment variable containing a list of folders separated by colons. When you write a command without a slash, the shell searches those folders in order and executes the first one it finds. "command not found" almost always means that the program is installed in a folder that is not listed in the PATH of that session (cron, a service, another shell), not that it is missing.
You write "ls" and the list of files appears. How did the system know where the "ls" program is?
With the PATH: an environment variable that contains a list of folders separated by colons.
$ echo $PATH /home/yo/.local/bin:/usr/local/bin:/usr/bin:/bin
When you write a command without a slash, the shell goes through those folders in order, from left to right, and executes the first executable file that matches that name. If it doesn't find it in any of them, it says "command not found".
That is the entire mechanism. And that is where almost all the problems come from.
Order matters, a lot
If the same name exists in two folders in the PATH, the one that comes first wins.
That is why personal folders usually go first: it allows you to have your own version of a tool without touching the system's version.
And that is also why baffling situations arise. You have two versions of Python installed, you run "python3" and the one you didn't expect comes up. The answer lies in the order of the PATH.
Two commands that resolve this in seconds:
which python3 # cuál se ejecutaría type -a python3 # todas las que existen, en orden
(which no ve los alias ni las funciones del shell; type sí.)
El segundo es el que de verdad aclara el panorama, y casi nadie lo conoce.
Los tres casos donde falla
1. En cron. Este es el más frecuente y el más frustrante.
cron ejecuta con un PATH mínimo, que suele ser sólo /usr/bin y /bin. Tu script anda perfecto cuando lo corrés a mano y falla en la tarea programada, porque el programa que usa está en /usr/local/bin y cron no mira ahí.
La solución es usar rutas completas en los scripts de cron, o definir el PATH al principio del crontab.
2. En un script con shebang.
#!/usr/bin/env python3
Esa forma busca python3 en el PATH, lo cual es bueno para la portabilidad (respeta entornos virtuales) y significa que el resultado depende del PATH de quien lo ejecute.
La alternativa, poner la ruta fija, es predecible y menos portable. Las dos opciones son válidas: lo importante es saber cuál estás usando.
3. Después de instalar algo y "no aparece".
Muchos instaladores dejan el ejecutable en una carpeta que no está en tu PATH, y te dicen que agregues una línea a tu configuración del shell. Si esa línea no se agregó, o se agregó en un archivo que no se lee en tu tipo de sesión, el comando "no existe".
Cómo agregarlo bien
En tu archivo de configuración del shell:
export PATH="$HOME/.local/bin:$PATH"
Dos detalles importantes:
- Always include $PATH at the end. If you write only the new folder, you erase everything else and the system becomes almost unusable in that session.
- Put the new folder at the front if you want it to have priority, or at the end if you prefer the system to win.
The security detail
Never put the current directory (a dot) in the PATH.
If you do, it is enough for someone to leave a file named "ls" in a folder you pass through for it to be executed without you realizing it. It is a classic attack vector and that is why no distribution includes it by default.
For the same reason, to execute something from the current directory you have to write ./program: that slash tells the shell "this is a path, do not search in the PATH".
How to diagnose a command that does not appear on the VPS
If you run command -v python3 or command -v node, the shell looks for the executable following the folders included in PATH. If the command does not appear, the package may be missing or its directory may not be included. The solution is not to download any file from the Internet and run it as root.
On an ArduMaker VPS you can open the terminal and check echo "$PATH", command -v and the actual service paths before modifying variables. Remember that systemd and interactive sessions may have different environments; a program that starts from your shell does not necessarily have the same variables when it starts automatically.
Related: Environment variables · What is Bash.
Frequently asked questions
Why does a script run manually but fail in cron? Because cron starts with a minimal PATH (usually /usr/bin and /bin). Use full paths or define PATH= at the beginning of the crontab.
How do I see which version of a command is being executed? type -a name lists all matches in PATH order; the first one is the one that runs.
Why is it not advisable to put the current directory (.) in the PATH? Because any file with the name of a common command in the folder you are in would run instead. To run something from the current folder, use ./program.