Thursday, December 18, 2014

file permission in linux

File Permission in Linux:
The linux file permission system is simple but flexible, which makes it easy  to understand. There are three categories of permissions :

                                          I.        Read
                                          II.        Write
                                         III.        Execute

Permission
Effect on files of permission
Effect on directories of permission
Read (r)
Contents of the file can be read
Contents of the directory can be listed
Write (w)
Contents of the file can be changed
Any file in the directory may be deleted or created
Execute (x)
Files can be executed as commands
Contents of the directory can be accessed

Root has the equivalent of the windows  full control permission on all files in linux.
Must Linux user will be familiar with the 'octal code', where a three- or four-digit code represents the permissions. Here the digits correlate with the sum of the different permission values.

 r = read permission = 4
 w = write permission = 2
 x = execute permission = 1

for example:
         # chmod 640 anshuman
Here 6= 4+2 means ( read and write permission) for owner.
4 means (only read permission) for group
0 means (no permission ) for other

For full permission in any file or directory we can use: 777

How to View the file permission:


You can view the permissions by checking the file or directory permissions in your favorite GUI File Manager or by reviewing the output of the "ls -l" command while in the terminal and while working in the directory which contains the file or folder. 




















How to change File permission:

The chmod command is used to change the various permission bits of a file or directory.
                   #chmod  777 anshuman.txt          (now full permission on this file)
                   #chmod 770 anshuman.txt   (now full permission apply on this file only for owner)

How to Change Ownership:

In order to check file ownership of users and group serve the two commands "chown" and "chgrp". Every file belongs to exactly one user and one group.
                     # chown user:harry anshuman.txt (  now harry is the owner of this file)
                   #chgrp user:mariya anshuman.txt (now group owner is maria)

No comments:

Post a Comment