Unix File and Directory Permissions


Let's examine the output from the ls l command. For example, type the following:

 >ls -l -rw-r--r-- 1 rob  rob     2024 Dec 25 20:22 39 atest.tar -rwxrwxr-x 5 rob  rob     1024 Dec 25 20:22 atest2.tar ... 

When considering file and directories, you have to understand the concept of ownership. Ownership is nothing more than noting who owns the file. Each file has information stored with it that identifies the account that owns it. From the example of ls l, you can see that I am the owner of the two files in my current directory: atest.tar and atest2.tar. Files are owned by those who create them, although ownership can be transferred.

Each file on the Unix system also has a secondary piece of information stored that records the group ownership of the file.

What Is a Group? The definition of a group is not very complex, but the application of it is. Groups are collections of users. By allowing a group to share ownership of files, many people can work together on a project and have their changes immediately available to other members of the group. Creation of groups is a system administration task, so if you need a group created for a project, talk to your system administrator.


Permissions, once applied, will control what a user (or group) can do to a file or directory. There are three basic actions, which are self-explanatory: read, write, and execute. We have already spent time covering what executables are earlier in the book. If you do not have the permissions such as read, write, or execute, then you will not be able to work with the files. It's really that simple.

  • Read permissions control whether someone can view a file.

  • Write allows or disallows changes to be made to a file.

  • Execute permissions control whether a file can be run, or executed.

Directory Permissions Specifics

We just covered files, but what about the directories that hold the files? Permission rights for directories are slightly different than those of files. If a directory has execute permissions turned off, you cannot change into that directory (using the cd command), view its contents, or write to it. It is effectively turned off. If read permissions are turned off, you can still create files in the directory and read them, but you cannot get a listing of what is in the directory. Lastly, if the write permission for a directory is turned off, you can view a listing of the contents and read files, but you cannot create any new files.

Permission Levels

When permissions are applied to a file or directory, they are applied at three specific levels: owner, group, and world.

  • The user (sometimes called owner) permissions simply control what permissions the file owner has.

  • Group permissions determine what actions can be performed by members of the same group to which the file belongs. Your system administrator can create new groups, or add you as a member of a group.

  • Other (sometimes called world) permissions are for a huge group that encompasses all the users on your computer. For example, email-related directories often assume other permissions.

If there is guest access to your computer, you can assume that any active other permissions apply to anyone who can access your computer.



    SAMS Teach Yourself Unix in 10 Minutes
    Sams Teach Yourself Unix in 10 Minutes (2nd Edition)
    ISBN: 0672327643
    EAN: 2147483647
    Year: 2005
    Pages: 170

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net