Add to Path Only SH File – Command-line Bash Execution

bashcommand lineexecute-command

I have a bin folder with a bunch of sh files. For example "server-run.sh", "server-stop.sh", "server-do-something.sh". And I want to run file "server-stop.sh" from anywhere. I could add this bin folder to path but "run" and "do-something" files also will be available and I don't want to pollute my console. Also I don't want to add this file to /bin folder, because it could change. Maybe link. Can I somehow add only "server-stop.sh" to path?

Best Answer

The best way is to add a symbolic link to this file in the /usr/local/bin directory:

cd /usr/local/bin
ln -s server-stop.sh /path/to/your/folder/server-stop.sh

In this case, you are adding a link to the original file, so you can always change the original file and you command will always be working.

Related Question