How to Make Shell Script Executable using command line

Hello everyone, today I am going to demonstrate some shell script tips and tricks. On my previous post, I have shown a simple shell script "Hello World" that can be read here. After we create a script, we need to make the script executable before we can actually run it.

For example, we already have a .sh file called hello.sh which contains some line of codes. We need to make the hello.sh file executable. Use the following command to make the hello.sh executable.

sudo chmod +x hello.sh

Now we can run the script with this command

sh hello.sh

or

./hello.sh

Its pretty simple but for a beginner, you must know it.


EmoticonEmoticon