chmod changes the permissions of each given file according to mode, where mode describes the permissions to modify. Mode can be specified with octal numbers or with letters. Using letters is easier to understand for most people.
$chmod
mode
The octal (0-7) value is calculated by adding up the values for each digit
User (rwx) = 4+2+1 = 7
Group(rx) = 4+1 = 5
World (x) = 4+1 = 1
chmode mode = 0751
Specific Mode
In the above example 0751 first digit 0 is the specific mode which can have following values
Execute only if the file is a directory
(or already has execute permission for some user) X
Set user or group ID on execution s
Save program text on swap device t
The permissions that the User who owns the file currently has for it u
The permissions that other users in the file's Group have for it g
Permissions that Other users not in the file's group have for it o
Alternate Way of Specifying the mode
Deny execute permission to everyone:
$ chmod a-x file
Allow read permission to everyone:
$ chmod a+r file
Make a file readable and writable by the group and others:
$ chmod go+rw file
Make a shell script executable by the user/owner
$ chmod u+x myscript.sh
Allow everyone to read, write, and execute the file and turn on the set group-ID:
$ chmod =rwx,g+s file