No such file or directory after typing $PATH in terminal
Solution 1
$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
.
Solution 2
In case you still don't get it from the other answers, it's the same as this:
$ echo the quick brown fox
the quick brown fox
$ the quick brown fox
bash: the: command not found
$ echo and/or the black and white cats
and/or the black and white cats
$ and/or the black and white cats
bash: and/or: No such file or directory
The first word of every command line has to be a command.
echo
is such a command.
the
, and/or
, and :/home/bo/bin:/usr/local/bin:/usr/sbin…
are not.
And, apparently, when you type a command line that begins with a word that isn't a command,
bash says No such file or directory
if the word contains one or more /
characters,
and command not found
if it doesn't.
Solution 3
By typing
$PATH
you are actually doing nothing else than expanding its content at command line:
:/home/bo/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/usr/bin:/sbin:/bin
and this is not a valid command, legitimately leading to the message you are getting.
What did you expect that typing only $PATH
will do?
Related videos on Youtube
wair92
Updated on September 18, 2022Comments
-
wair92 over 1 year
when I write in terminal
echo $PATH
my output is
:/home/bo/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/usr/bin:/sbin:/bin
but when I write just :
$PATH
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.
-
iDrwish over 5 yearsI guess the expectation that
$PATH
would essentially print the variable to the screen without trying to execute it, however, this is not the case.