0

When I type this in sh it outputs :

$ $PATH
sh: 12: /bin:/usr/bin: not found

But, I do have a /usr/bin folder, and it's fuuuuull of stuff.

Same thing with zsh:

▶ $PATH
zsh: no such file or directory: /bin:/usr/bin

What the hell ? How do I fix this ?

4
  • What command are you trying to run? Are you trying to find a command that is in your path?
    – DavidPostill
    Commented Jun 25, 2015 at 21:16
  • @DavidPostill I thinks he is directly writing $PATH and executing it. Commented Jun 25, 2015 at 21:17
  • 1
    @RakholiyaJenish Yes, that is clear. But why is he doing that? What's he really tryng to do?
    – DavidPostill
    Commented Jun 25, 2015 at 21:19
  • I think you are trying to run echo $PATH?
    – xuhdev
    Commented Jun 25, 2015 at 21:20

1 Answer 1

2

PATH is an environmental variable in Linux and other Unix-like operating systems that tells the shell which directories to search for executable files (i.e., ready-to-run programs) in response to commands issued by a user.

To see the value of PATH variable, do it as echo $PATH. In your case, sh will look for executable in /bin and /usr/bin directory.

Also, you can use your sh commands as /bin/command if the executable of command is in the /bin directory. For example, instead of using ls you can use /bin/ls since writing ls runs the executable ls present in /bin. If the ls is not there in /bin, then it will look in /usr/bin. If ls is still not found in both the directory, then it will complain.

Trying to use $PATH or /bin:/usr/bin: directly, sh thinks that it is supposed to run bin executable located in the directory /bin:/usr/. This is the reason, it give directory or file not found or not found error.

For detailed info on PATH.

2
  • So, when I run this : ▶ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/media/HDD/Code/android-sdk-linux/plateform-tools:/media/HDD/Code/android-sdk-linux/tools They are no more errors, and none in sh
    – dv4RqQUh
    Commented Jun 25, 2015 at 21:37
  • 1
    @N07070 Thats because, PATH is an environmental variable, which you are printing using $PATH. Hence, there won't be any error. Commented Jun 25, 2015 at 21:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .