Go4Expert (http://www.go4expert.com/)
-   Unix (http://www.go4expert.com/articles/unix/)
-   -   Understanding Unix/Linux File Permissions Representations (http://www.go4expert.com/articles/understanding-unix-linux-file-t27019/)

lionaneesh 26Oct2011 13:21

Understanding Unix/Linux File Permissions Representations

What Unix / Linux File Permission is?

Every File or directory in the Linux Operating system has an access level which specifies the group or the users can actually access it. Linux Provides us with mainly 3 access levels for each user group i.e. Read , Write and Execute. These permissions can be set for 3 types of users aka owner, owner's group and other users on the system.

For e.g. If I have a file named passwd.txt sitting on my Linux maching, I can totally control who can access it and what access rights are given.

In this tutorial, We'll be looking at some of the standard permission notations and what these notations actually mean.

Different Types of File Permission Representation

1. Textual Representation of Linux/Unix File Permissions

The textual representation consists of 10 characters in which the first character shows filetype and the rest of all shows the permissions. These permissions are further divided in three groups owner , group and others.The first character is left as '-' if its a file and 'd' if its a directory.Each group have 3 symbols , rwx [STANDS for READ , WRITE , EXECUTE permissions], If any of them is denied it replaced by a '-'

Now that we know all about these rules so lets take an example and try to understand it.

Example :-

File Type :-

The first thing to notice is the first character its a '-' so in this case the permission representation is that of a file.

Permissions :-

Followed by the first character there are 3*3 ( = 9 ) characters and they all (taken in sets of 3) represent the permissions of a specific groups which are owner , group and others .

In our case its :-

rwx (Read , Write and Execute) for Owner.
r-x (Read and Execute) for Owner's Group.
r-x (Read and Execute) for Other Users.

Here's and Exercise for you to practice :-

Specify the File-type and Permissions (given to each group) in the following representation

2. Numerical Representation (Octal) of Linux/Unix File Permissions

The Numerical Representation is mainly in Octal format and It consists of numbers from 0-7 , the main usage and speciality of Octal representation is that its very simple and short , each octal number include read write and execute permissions of a group. e.g. “422” indicates permissions given to all the 3 groups , including “4” for owner , “2” for group , “3” for other users. Don't worry if you don't understand what these actually mean , we'll be covering that in this tutorial.

The Below Table Shows Some of the Octal Digits and their Permission equivalent :-

| Octal | Textual | Meaning 
|  0  |  ---    | No Access
|  1  |  --x    | Execute Access
|  2  |  -w-    | Write Access
|  4  |  r--    | Read Access

These above are the basic octal codes u need to remember and after that rest of them you can construct on your own.

Eg :-

7    = 1+2+4  = Execute , Read , Write Access
6    = 2+4    = Write and Read Access
3    = 1+2    = Write and Execute Access

Now that we understand the basic rules of this representation now lets apply this knowledge to some basic examples.

Now in the above representation we have “7” for Owner , Group and Others , So as we know 7 stands for Read Write and Execute permission the above representation basically means we are providing read write and execute permission to all the 3 groups.


Find the meaning of the following Octal Representations


That's all for this tutorial

Thanks for reading and stay tuned for more.

lionaneesh 26Oct2011 14:23

Re: Understanding Unix/Linux File Permissions Representations
Thanks for Accepting! :)

All times are GMT +5.5. The time now is 03:16.