How to Make a Bash Script Executable

How to Make a Bash Script Executable

Bash scripts can be used to automate bash shell commands, they have the extention .sh. I personally use these to do some repetitive tasks like deploying a new post to this site.

To run a bash script you need to use the following command syntax in the command line:

sh ./address/

But the script is not executable by itself, to make it executable follow the following steps

1. Add approriate shebang

For bash add the following shebang at the top of the script


2. Run the chmod command for the file

Go to the directory containing the script and use the following command

chmod u+x

3. Run the script

To run the script in the same directory


For any other directory