Execution

To run / execute a script it must have its execute permission set.

 

This can be achieved for all users by:

chmod +x myscript.sh

 

Alternatively, specific user, group, others can be set by preceding the x by the appropriate flag:

  • chmod +ux myscript.sh where u stands for user
  • chmod +gx myscript.sh where g stands for group
  • chmod +ox myscript.sh where o stands for others
  • chmod +ax myscript.sh where a stands for all
    • this can also be achieved by omitting the permission identifier chmod +x myscript.sh as per above

The script may now be executed:

./myscript.sh

 

Alternatively, you may also use sh before the script name to run it:

sh myscript.sh