1

This question already has an answer here:

here is the output of echo $PATH

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin

and when I gave cat /etc/paths this is the output

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

I am not sure whether that /usr/local/bin is creating the error (command not found)

Thank u for your suggestions

marked as duplicate by bmike Oct 1 '15 at 14:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • in Terminal, press Cmd-T to open a new tab. Do the commands work there? – nohillside Sep 29 '14 at 14:04
  • no it does not... do i have to change the directory to that particular library (to run the command every time). – MrMsarguru Sep 29 '14 at 14:06
  • Do you get the error message for all commands you are trying to execute or only for some? if the second, for which? – nohillside Sep 29 '14 at 14:32
  • I figured out a solution.. but not sure if its correct.. I HAVE THIS LIBRARY (with executable file) TO DO SOME STATISTICS .... so I moved the exec.files to the usr/local.bin and the command works fine.... IS IT OK – MrMsarguru Sep 29 '14 at 14:36
  • Yes, putting an executable file in /usr/local/bin is fine. – Trane Francks Sep 29 '14 at 14:50
1

Commands you run in Terminal need to either in one of the directories included in $PATH or you need to call them with ./command if you are in the directory the command is stored in.

-1

I suggest you run this command, it should re-build the PATH variable.

/usr/libexec/path_helper

  • 1
    Drive-by downvoter: Would you care to explain why? – JRobert Sep 30 '14 at 11:20
-2

What concerns me is that you're getting duplicates in your path. Have you added something to your ~/.bash_profile? You want to be very careful that you're not duplicating any of those existing path declarations in whatever you're doing. It's fine to modify PATH, but you want to be careful with it. Here's an example:

PATH=$HOME/.rvm/usr/bin:$HOME/.rvm/bin:$PATH

Note that I add my own stuff and then tack on the system stuff at the back with $PATH.

Other things to check are making sure that you're not sourcing any unnecessary scripts during login that might muck with your environment. Be sure that if you're using a non-standard editor that you're saving in UNIX format. If you accidentally do things with DOS CRLFs, that can trigger command not found errors.

And just on the off chance that you've nuked your ~/.bash_profile, i.e., you absolutely don't have one anymore because you deleted it:

echo "" >> ~/.bash_profile

That is an odd one, but I've seen at least one guy claiming that command not found issues were fixed by creating a missing .bash_profile.

Finally, note that if you do not wish to give a full path to the executable that you're running, e.g., ~/Downloads/myScript.sh, you need to either place the executable somewhere in your existing path or you need to modify your path to point to the directory in which your executables are stored.

  • -2 down vote accept What concerns me is that you're getting duplicates in your path. Have you added something to your ~/.bash_profile? You want to be very careful that you're not duplicating any of those existing path declarations in whatever you're doing. ----- Thanks for the suggestions - how can revert it back and not duplicate the paths!! thanks in advance for any suggestions – MrMsarguru Sep 29 '14 at 15:10
  • It all depends on whatever changes you've been making in order to get things working. As it is now, nothing in the PATH statement will damage anything. Duplicates do, however, indicate that something isn't quite right. Examine any of the files you've changed the PATH in and eventually you'll find your duplication. – Trane Francks Sep 29 '14 at 15:42

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