chmodChange file mode bits; this is used to change the files' permissions.
The three types of permission are read (r), write (w) and execute (x).
chmod allows the user to change the permissions in two ways - Symbolic permission and numerical (octal) permission.
Symbolic permission: A combination of the letters u g o a controls which users' access to the file will be changed: the user who owns it (u), other users in the file's group (g), other users not in the file's group (o), or all users (a) [default].
The operator + causes the selected file mode bits to be added to the existing file mode bits of each file; - causes them to be removed.
Example:
Adding the execute permission for others.
$ chmod o+x file.txt
Removing the execute permission for the user.
$ chmod u-x file.txt
Numerical (Octal) permission: A 3-digit octal number (say abc) is used to specify the permissions i.e., digit a specifies the user permission, digit b specifies the group's permissions and c specifies other's permissions.
3 binary digits (say def) are required to represent a single-digit octal number. Each digit in the binary number represents the read, write and execute permission i.e., bit d - read, e - write and f - execute. Refer to the below table for better understanding.
//tab
+-------------+--------+-------+
| Permissions | Binary | Octal |
+-------------+--------+-------+
| --- | 000 | 0 |
| --x | 001 | 1 |
| -w- | 010 | 2 |
| -wx | 011 | 3 |
| r-- | 100 | 4 |
| r-x | 101 | 5 |
| rw- | 110 | 6 |
| rwx | 111 | 7 |
+-------------+--------+-------+
Example:
Removing permissions for all
$ chmod 000 file.txt
Adding rwx permission for user, rx permission for group and x permission for others.
$ chmod 751 file.txt
chownChange file owner and group.
chgrpchgrp : Change group.