Command line app location? (OSX)

applicationscommand linegeolocation

I wrote a small tool as a cmd tool. Where should it be placed? Which paths are automatically scanned for searching an app? I want to avoid absolute path, because I have to track it on every system.

Best Answer

In a Terminal type echo $PATH and press Enter. It will display your PATH Environment Variable.

Example:

 $ echo $PATH
 $ /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
 $

While you could place it in any of the locations listed nonetheless it's a good suggestion that you place it in /usr/local/bin as the other locations are used by the OS. In a Terminal see man hier for an explanation of the layout of the filesystem in this respect.

On my system I have hundreds of scripts I've written, over the years, and use many on an ongoing basis so I created a directory in the root "/" directory called scripts and place everything there and added /scripts to my PATH by adding export PATH=$PATH:/scripts to my ~/.profile file.

So my PATH is as follows:

 $ echo $PATH
 $ /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/scrips
 $