Understanding Unix/Linux File Permissions Representations

Discussion in 'Unix' started by lionaneesh, Oct 26, 2011.

  1. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India

    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 :-
    Code:
    -rwxr-xr-x
    
    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
    Code:
    drwxr-xr-x  
    
    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 :-
    Code:
    | 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 :-
    Code:
    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.
    Code:
    777
    
    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.

    Exercise



    Find the meaning of the following Octal Representations
    Code:
    024
    123
    333
    444
    764
    
    That's all for this tutorial

    Thanks for reading and stay tuned for more.
     
  2. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India
    Thanks for Accepting! :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice