Tuesday, August 7, 2012

FILE AND FOLDER PERMISSION IN LINUX

Permissions –

#chmod
           As shown in the output of ls -l command above, each and every file has the permissions associated with it. These permissions are defined for three types of persons namely- the owner of the file, the group members of the owner, and all other persons who are not the members of the group whom this owner belongs to. Let us have a look on following line:


-rwxrw-r--   1   root   root   468   Aug   8 07:15   file1

Permissions are defined within first ten characters of the above like output from ls -l. normally, the first character can either be - or d, - represents that it is a file while d represents a directory. Remaining characters are grouped in set of three characters which are r (read), w (write), and x (execute).
In the above example first three characters are rwx which means owner of the file has all the permissions on file1. Next three characters are rw- which will mean the group members will have read and write permission on file1 but not execute permission on it. The last set is r—which will mean that others will only have read permission on file1 but they will not have write and execute permission on file1.

Note –
        The default permission for file is 664 and for directory 755. 
The value of permission –

444 are set the read only permission:-

7                 :               rwx
0                 :               no permission
6                 :               rw
4                 :               r only
2                 :               write x

#chmod –
       This command is used to set permission of the file.

Example –
               Chmod   700   filename
               7 for owner
               0 for group owner
               0 for every one

#chown –
      This command is used to set the permission for the owner.

Example –
            #chown   root   filename

Syntax:-
        Chown command for change owner ship root presented owner.

#chown   ram: ram   name.conf

We can set the permissions by using chmod command. For example, for setting the permissions as above us can run the following command:

#chmod   764   file1

We can use the following example to find any type of permission, we want to set.


No comments:

Post a Comment