Setting permissions in files and folders in Linux
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
Setting permissions in files and folders in Linux
Rating:
Linux has three types of permissions that can be assigned to users or groups. These permissions have been described in the table below:
| Read | The Read permission, represented by "r", allows users or groups to read the files or folders for which this permission has been granted. |
| Write | The Write permission, represented by "w", allows users or groups to make modifications in the files or folders for which this permission has been granted. This permission also allows deleting files or folders. |
| Execute | The Execute permission, represented by "x", allows users or groups to execute or search the files or folders for which this permission has been granted. |
The permissions on a file or folder are represented in the following format:
rwxrwxrwx
Basically, this is a group of three permissions. The first three characters are for the owner (user) of a file or folder, the next three characters are for a group, and the last three characters are for others.
Linux uses numbers to set permissions on files and folders. The numbers are from 0 to 7. Each number corresponds to a setting of Read, Write, and Execute permissions.
Following is the number chart of permissions:
| 0 | No | No | No |
| 1 | No | No | Yes |
| 2 | No | Yes | No |
| 3 | No | Yes | Yes |
| 4 | Yes | No | No |
| 5 | Yes | No | Yes |
| 6 | Yes | Yes | No |
| 7 | Yes | Yes | Yes |
To set the permissions, you use a set of three numbers. The first number belongs to the owner, the second number belongs to a group, and the third to others.
In order to grant Read, Write, and Execute permissions to the owner, to a group, and to others, you will have to set permissions as 777. The first number 7 will provide r, w, x permissions to the owner. The second and third 7s will provide the same permissions to the group and to others, respectively.
Similarly, if you do not want to provide w, r, and x permissions to others, you will have to set the permissions as 770.
By listing the folder, you will get the following result:
You can see that David already has r, w, and x permissions, whereas the JAdmin group and others have only r and x permissions. Now, as you do not want to give others any access to the Crack folder, you will have to execute the following command:
This will meet all the necessary requirements of the scenario. Listing the folder will provide you the following result:
Rating:
Was this information helpful?
Other articles
- What is /dev directory?
- What is the MKINITRD command?
- What is the FIND command?
- What is PASSWD command?
- What is 3DES?