Syntax:
Role & Permission Types
To understand file permission you must know about Roles and Permission types. There are three types of roles available in Linux systems (User, Group, and Others). Each role has 3 types of permissions (Read, Write, and Execute).
Roles:
User (Owner) Group (All group members) Other (All other users
Permissions:
Read (r) – Member can read the file content or List files in a directory Write (w) – Member can write content to file or Create, list, rename, delete file in a directory Execute (x) –< Member can execute any file like sheel script or enter to the directory, and access files and directories
Changing File Permissions in Linux
The chmod command allows users two ways to set permission on any file. Read below about both options:
Using Symbolic Notation
Just for the reminder, the following symbols are used for file permissions. Here roles are User(u), Group(g), Others(o) and the permissions are Read(r), Write(w), Execute(x). Roles:
u – User g – Group o – Other
Permissions:
r – read permission w – write permission x – execute permission
You can combine any symbols to set permission together like User+Group (ug), User+Group+Other (ugo), User+Other(uo). Similarly, you can do the same with permissions like Read+Write (rw), Read+Execute (rx), Read+Write+Execute (rwx). User => Read + Execute User + Group => Read + Execute User => All, Group => Read + Execute, Other => Read User => All, Group + Others => Read + Execute All permission to everyone (not recommended)
Using Octal Notation:
Using the octal notation you can set permissions in number between 0-7. Each number is calculated with the sum of read (4), write (2) and execute (1). For example, if you set permission 6, it means 4+2 (read + write). If you set permission 5 means 4+1 (read + execute). The permissions are set in a sequence user, group, others. For example if you set permission 754, it means user => 7, group => 5 and other => 4. Let’s have some examples.
Read (r) – 4 Write (w) – 2 Execute (x) – 1
Possible combinations as as follows: Example: User => read+write+execute, Group => read+execute, Other => read Here:
7 is for user is combined with read-4 + write-2 + execute-1 5 is for group is combined with read-4 + execute-1 4 is for other is read-1 only.
User => read+write, Group => read+write, Other => read