Linux – No such file or directory after typing $PATH in terminal


when I write in terminal

echo $PATH

my output is


but when I write just :


this output I do not understand right, output is:

bash: :/home/bo/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/usr/bin:/sbin:/bin: No such file or directory

and my question is, why did it write "No such file or directory?" every directory from PATH variable exists.

Best Answer

$PATH is a variable, which I am sure you're aware of. When that variable is resolved, it would be the same as typing in :/home/bo/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/usr/bin:/sbin:/bin: and expecting something to happen. The reason echo $PATH works is because you're explicitly piping it out to the display rather than telling the terminal to "do" $PATH.