executing shell script without calling sh implicitly executing shell script without calling sh implicitly shell shell

executing shell script without calling sh implicitly


Make the first line of the script

#!/bin/sh

Then make it executable by typing the command:

chmod +x shellscript.sh

If you now place the script in a bin folder that is on your system's PATH variable and you will be able to run it directly. To see the folders in your path, type:

echo $PATH

I usually use /home/[my username]/bin for scripts that I have written so that they don't interfere with other users on the system. If I want them to be for all users, I use /usr/local/bin which is supplied empty on most distributions.

The .sh on the end of the script's filename is only a convention to help you remember what kind of file it is. It will still work if you rename it to just shellscript, for example, which will complete your requirements.


You can make the shell script executable (chmod +x shellscript.sh). Then you can link to it from /usr/bin (ln -s shellscript.sh /usr/bin/shellscript).


Yes. You can use ln to create a link to shellscript.sh named shellscript. You will then need to make it executable, but after that (assuming /usr/bin is on your path) you can run it with shellscript.