Tuesday, November 3, 2009

File Permissions









File Permissions


Because Linux is a multi-user system, directories and files need to be protected from unauthorized use. Each directory and file has associated permissions, settings that determine who can access the file and what they can do with it.


Permissions to the file are given to three types of user accounts:



  • Owner:
    The account that owns the file


  • Group:
    Members of a group that owns the file


  • All users:
    All accounts on the system


Users can be given permission to do one or more of three things to the file:



  • Read:
    Look at the contents of the file


  • Write:
    Save the file to the hard disk


  • Execute:
    Run the file or enter the directory


The permissions can be given in any combination. For instance, file1 might have permission as follows:



  • Owner:
    Read, write, execute


  • Group:
    Read, execute


  • All users:
    Read


The owner can look at, edit, save, and run the file. Members of the group can only look at and run the file, but they can't change it. Everyone on the system can look at the contents of the file. Remember that a directory is simply a file, so directories can be given the same type of permissions as a file.


File permissions are often displayed in a shorthand format as follows:



rwxr--r--


The r, w, and x stand for read, write, and execute, as described earlier in this section. The 9 characters shown represent three groups of three: rwx and r-- and r--. The first group displays the permissions for the owner, the second is the permissions for the group, and the third is the permissions for everyone. Thus, in this case, the owner can read, write, and execute the file, but the group and all users can only read the file, not write/execute it. Only the owner or the root account can change file permissions.









    No comments:

    Post a Comment