Here is a script file(/home/anuj/myscript/myscript.sh) which echo’s current directory on the terminal.
2. Make a symbolic link mycommand pointing to myscript.sh in /usr/bin or /sbin/ or /usr/sbin directory (Differences between them can referred from here).
cd /sbinln -s /home/anuj/myscript/myscript.sh mycommand
Now you can use command “which” to see which file will executed if we type the command named “mycommand”
Its done! 🙂 Next question would be where we can use it to make our life easier??. Well ! Generally we have deployment script for that we need to switch to user and then we need to run the script file instead of doing that we can make a softlink of the script file and put it in the /sbin or /usr/sbin etc. Like some software packages like apache put softlink to there script file in /sbin.e.g. a2ensite is a softlink to a2enmode in /usr/sbin which is a executable script file.
There can be some better way to achieve the same so suggestions are most welcomed.
Hope this helps you guys !