The chmod command changes the file mode (permissions) of each given file according to the mode specified. The mode can be specified in three ways:
1. Numeric mode: This method uses a three-digit number to represent the permissions for the file owner, group owner, and others. Each digit represents a combination of read, write, and execute permissions, and can be calculated by adding the values of the individual permissions. For example, '7' represents read, write, and execute permissions (4 + 2 + 1), '6' represents read and write permissions (4 + 2), and '5' represents read and execute permissions (4 + 1).
To change the permissions of a file using numeric mode, use the following command:
chmod <mode> <file>
For example, to give the owner read, write, and execute permissions and the group and others only read and execute permissions, you can use:
chmod 755 myfile.txt
2. Symbolic mode: This method uses symbolic representations of the permissions to change the permissions of a file. The symbols used are '+', '-', and '=' to add, remove, or set the permissions respectively. The symbols are followed by 'r', 'w', or 'x' to represent read, write, or execute permissions, and can be applied to the owner, group, or others. For example, '+r' adds read permission, '-w' removes write permission, and '=x' sets execute permission.
To change the permissions of a file using symbolic mode, use the following command:
chmod [who][operator][permission] <file>
For example, to give the owner read and write permissions, and remove execute permission for the group and others, you can use:
chmod u+rw,g-x,o-x myfile.txt
3. Alphabetic mode: This method is similar to symbolic mode, but uses letters to represent the permissions instead of symbols. The letters used are 'r', 'w', and 'x' for read, write, and execute permissions, and can be applied to the owner, group, or others. The letters are followed by '+' or '-' to add or remove the permissions.
To change the permissions of a file using alphabetic mode, use the following command:
chmod [who][operator][permission] <file>
For example, to give the owner read and write permissions, and remove execute permission for the group and others, you can use:
chmod u+rw,g-x,o-x myfile.txt
Note that in all modes, the u represents the owner, g represents the group, and o represents others. You can use a combination of these letters to change the permissions for multiple categories at once.