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.
In a Terminal type
echo $PATH and press Enter. It will display your
PATH Environment Variable.
$ 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
PATH is as follows:
$ echo $PATH $ /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/scrips $
The usual Unix way for your scripts is /usr/local/bin for scripts that all users on the system can use and if for only you then in somewhere under your home directory often ~/bin
You need to make sure both of these directories art on your PATH environment variable preferably before system paths do if your write a script with the same one as a system one then your one gets run.
e.g in you shell (usually in ~/.bashrc)