what is Linux File Permission?

Every file, directory, and other system objects in Linux are assigned an owner and a group. Owners, users belonging to a group, and all others may be granted different types of access to read from, write to, or execute files. ... This is generally referred to as file permissions in Linux. 



Subject: Linux Administrator                                                      Exp No.  5   

 

Aim of the Experiment: Linux File Permission

 

 

Software Required:

1.     VMware

2.     Rhel 7.0

 

 

 

 

 

Theory:   To change directory and file permission in Linux, Each file and directory in Linux has three permission levels which define how a user can access a particular file or directory. These levels are user/owner, group and other. Each permission level has three type of permission; read, write and execute. This type of permission defines what a user can do with a particular object.




owner: The Owner permissions apply only the owner of the file or directory, they will not impact the actions of other users.

group:  The Group permissions apply only to the group that has been assigned to the file or directory, they will not effect the actions of other users.

other: The other permissions apply to all other users on the system.

            Each file or directory has three basics permission types:

read: The Read permission refers to a user’s capability to read the contents of the file.

write: The Write permissions refer to a user’s capability to write or modify a file or directory.

execute: The Execute permission affects a user’s capability to execute a file or view the contents of a directory.

 

 

Implementation/Steps:  

            To check the permission :                   ls –l

            To see hidden file/directory also        ls-al

           

            It will show in this form:                    -rwxrw-r-- OR rwxrwxrwx

 

            Firtst hyphen ‘-’  It shows type of file

            Suppose a file is there, name diploma  and its permission  is  rwxrw-r--

        

                        rwx:  Read Write Execute

                        rw-:  Read and Write

                        r--:  Only read



 

            First group defines: Owner can read, modify and execute the diploma file.

            Second groups:        Group can read and modify the file, but can’t execute

            Third group:            Others can read only the diploma file. 

           

Now to Change the permission 

                        command is      chmod

            To add the permission we use ‘+’

            To remove the permission we use ‘-’

           

                        chmod g+x diploma           now group members can execute the diploma file

                        chmod o+w diploma          Now others can modify the file

                        chmod g-w diploma            Now group members cant modify the file

                        chmod u-x diploma             Now owner cant execute the file diploma

 

we can do it by using Number also:

            We will use command            chmod

                        To set permissions of diploma to –rw-r—r--           chmod 644 diploma

                        To set permission of diploma to –rwxrwxrwx         chmod 777 diploma

                        To set permission of file1 to drw-rw-r--                   chmod 664 file1

                        To set permission of file2 to  -r---w---x                    chmod 421file2

 

umask

                        We can set the file permission by using umask value.

                        To check the umask value                 #umask                        :022(mine)           

           

A umask of 022 basically means don't remove any permissions from the base value for "user" but "group" and  "other" is not allowed write permission     

                                    777-022= 755

                        So the command is..               chmod 755 file_name

           

Like this we can change the access permission of a particular file…

 

                       

                                   

                         

                       

 

Conclusion:  In this experiment I learned to change the file access permission with two commands chown and chmod.  And get familiar with umask. Now I can change any file permission by using these command…

                       

 

                                                                                                 

 

                                                                                

 

 

 

Post a Comment

Previous Post Next Post