File Access Permissions in Linux
Permissions are access rights, for files and directories, given to specific users or groups of users. Permissions control the ability of the users to view or modify the contents of the filesystem. Linux and other unix systems work in similar way.
There are three classes to whom permissions are given:
- User: Owner of file or directory
- Group: Other users in group
- Others: Everyone else
Permissions
There are three specific permissions (not to confused with three classes) that apply to each class - Read, Write ans Execute.
The read permission grants the ability to read a file. When set for a directory, read permission grants the ability to read the names of files in the directory.
The write permission grants the ability to modify a file. When set for a directory, write permission grants the ability to modify (create, delete, rename) entries in the directory.
The execute permission grants the ability to execute a file. Execute permission must be set for executable binaries or shell scripts to allow operating system to run them.
Symbolic Notation
In symbolic notation, there are ten characters. The first character indicates the type of file and is not related to permissions. Remaining nine characters are in three sets, each representing a different class (User, Group, Others). Thus, there are 3 triads. First traid for user, second for group and third for others. Three characters in each triad are for r, w and x.
- r - readable
- w - writable
- x - executable
Lets see an example:
-rwxr-xr-x
User class has full permissions (rwx) and whose group and others classes have only the read and execute permissions (r-x).
Octal (Numeric) Notation
This notation consists of three digits. Forst digit is for user, second for group and third for others. Each digit can be 0, 1, 2, 3, 4, 5, 6 or 7 depending upon permissions. Now how to convert from symbolic notation to octal notation. Just remember: rwx to 421. What it means? Read permission is 4, write permission is 2 and execute permission is 1. To give combination of permissions, add the digits.
lets say, you want to give all three permissions - rwx, then add 4+2+1=7.
Above access right (-rwxr-xr-x) in octal notation is 0755.