Mighty Chmod

The chmod command in Linux is used to modify the permissions and access mode of files and directories. These are the permissions that control who can read, write and execute the file.

Two types of modes for specifying permission: symbolic and octal mode. In symbolic mode, one uses letters and operators to specify the permission. Whereas octal has a three-digit number for specifying the permission.

In octal method we specify permission using three-digit number. Where..

  • First digit specify the permission for Owner.

  • Second digit specify the permission for Group.

  • Third digit specify the permission for Others. The digits

    NOTE: The digits are calculated by adding the values of the individual permissions.

ValuePermission
4Read Permission
2Write Permission
1Execute Permission

Octal method is the most widely used type .

  1. How to change permissions of multiple files at the same time ?

    Answer : Suppose you want to change permissions of all the text files in a directory /home/ubuntu/dev .

    chmod 755 /home/ubuntu/dev *.txt

  2. How to change permissions of more than one different type of file ?

    Answer : Suppose you have two files sum.sh and calc.txt you want to change permissions on these 2 files .

    chmod 766 /home/ubuntu/dev sum.sh calc.txt