chmod
Syntax: chmod 755 swamprocks
Changes the permissions (or mode).
Here, the user (owner) is being given executable privileges on the
specified filename (swamprocks) or directory.
The three permissions are read, write, or executable: who may view, modify, and execute the file, respectively. The three groups who for whom this is delegated are the
user, who is the owner of the file, the user's group, and all others.
chmod permission
your-script-name
Examples
$ chmod
+x your-script-name
$ chmod
755 your-script-name
Options Type A
rwx rwx rwx | | | 1 2 31 – owner
rwx rwx rwx
421 401 021
For owner add this number as 4+2+1 = 7
For group add this number as 4+0+1 = 5
For others add this number as 0+2+1 = 3
So command will be $ chmod 753 filename
Examples
$chmod 755 first.sh
Options Type B
chmod {u|g|o|a} {+|-} {r|w|x} {filename}
u - User who owns the file
g - Group file owner
o - User classified as other
a - All other system user
+ Set permission
- Remove permission
r - Read permission
w - Write permission
x - Execute permission
Examples
$ chmod u+x,g+wx,o+x myscript
Above command set permission for file called 'myscript' as User (Person who creates that file or directory) has execute permission (u+x) Group of file owner can write to this file as well as execute this file (g+wx) Others can only execute file but can not modify it, Since we have not given w (write permission) to them. (o+x).