File Ownership

Every file belongs to both a user and a group−−usually to the user who created it and to the group the user was working in at the time (which is almost always the user's login group). File ownership determines the type of access users have to  particular files

Determining the Ownership of a File

To find out which user and group own a particular file, use ls with the `−l' option to list the file's attributes (see section Listing File Attributes). The name of the user who owns the file appears in the third column of the output, and the name of the group that owns the file appears in the fourth column. For example, suppose the verbose listing for a file called `cruise' looks like this:

−rwxrw−r−− 1 captain crew 8,420 Jan 12 21:42 cruise

The user who owns this file is captain, and the group that owns it is crew. NOTE: When you create a file, it normally belongs to you and to your login group, but you can change its ownership, as described in the next recipe. You normally own all of the files in your home directory.

Changing the Ownership of a File

You can't give away a file to another user, but other users can make copies of a file that belongs to you, provided they have read permission for that file. When you make a copy of another user's file, you own the copy. You can also change the group ownership of any file you own. To do this, use chgrp; it takes as arguments the name of the group to transfer ownership to and the names of the files to work on. You must be a member of the group you want to give ownership to.

To change the group ownership of file `cruise' to bridge, type:

$ chgrp bridge cruise RET

This command transfers group ownership of `cruise' to bridge; the file's group access permissions now apply to the members of the bridge group. Use the `−R' option to recursively change the group ownership of directories and all of their contents. To give group ownership of the `maps' directory and all the files it contains to the bridge group, type:

$ chgrp −R bridge maps RET

Posted on: 16/12/2009

If you want to leave a comment please Login or Register
How to backup your data using rsync......
Understanding autoconf......
The Basics of fdisk......
Accessing Memory Using DMA......
The fd Directory......