Setting up permissions on a script
From Linux Shell Scripting Tutorial - A Beginner's handbook
| ← Shell Comments | Home | Execute a script → |
The chmod command (change mode) is a shell command in Linux. It can change file system modes of files and directories. The modes include permissions and special modes. Each shell script must have the execute permission. Mode can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits.
[edit] Examples
Allowing everyone to execute the script, enter:
chmod +x script.shOR
chmod 0766 script.sh
Only allow owner to execute the script, enter:
chmod 0700 script.sh
OR
chmod u=rwx,go= script.sh
OR
chmod u+x script.shTo view the permissions, use:
ls -l script.sh
Set the permissions for the user and the group to read and execute only (no write permission), enter:
chmod ug=rx script.sh
Remove read and execute permission for the group and user, enter:
chmod ug= script.sh
[edit] More about chmod
Type the following command to read chmod man page:
man chmod
Please note that script must have both executable and read permission.
[edit] External links
| ← Shell Comments | Home | Execute a script → |

