0

I'm trying to understand the whole $PATH problem but I've got no luck so far. Suppose that I've just compiled an executable with make and I need to launch it with the shell without using the full path. Well the problem is that I don't fully understand all these "add to path" things.

My idea is that if the terminal reads on specific folders, why don't we just put all the application files to this folder?

Why don't we add the whole Applications folder to the list of folder that the terminal goes to open an application?

  • 1
    You have a lot of questions here that probably deserve their own post. – samh Dec 3 '15 at 11:54
  • You CAN open any application without adding them to path. Just do open -a Safari, do man open to find out more. – user14492 Dec 13 '15 at 8:48
1

The PATH variable already containts a list of directories which the shell (which is what is running inside Terminal) is using to search for any executables. So if you compile something on your own and put it into one of the folders listed in PATH you can execute it from the shell prompt right away.

The current folder (.) usually is not part of PATH for security reasons. So for stuff you compile and want to run right away, you have to execute ./stuff for the shell to find it.

  • Plus you would need to rehash to get a new executable on the path – Mark Dec 3 '15 at 14:26
  • Rehashing is only required if the shell already knows the location of an executable (aka you've called it before) and you put a replacement into another directory listed in PATH. – nohillside Dec 3 '15 at 14:59

You must log in to answer this question.

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