User and Group Ownership


Let's pretend you have a file called mail_test and you want to change its ownership from the root user to natika. You first have to log in as root, because only root can change root's ownership of a file. This is very simple:

 chown natika mail_test 

You can also use the -R option to change ownership recursively. Let's use a directory called test_directory as an example. Once again, it belongs to root and you want to make every file in that directory (and below) owned by natika:

 chown  R natika test_directory 

The format for changing group ownership is just as easy. Let's change the group ownership of test_directory (previously owned by root) so that it and all its files and subdirectories belong to group accounts:

 chgrp  R accounts test_directory 

You can even combine the two formats. In the following example, the ownership of the entire finance_data directory changes to natika as the owner and accounts as the group. To do so, you use this form of the chown command:

 chown  R natika.accounts finance_data 

Quick Tip

You can use the -R flag to recursively change everything in a subdirectory with chgrp and chmod as well.


So now files (and directories) are owned by some user and some group. This brings us to the next question.



Moving to Linux(c) Kiss the Blue Screen of Death Goodbye!
Moving to Linux: Kiss the Blue Screen of Death Goodbye!
ISBN: 0321159985
EAN: 2147483647
Year: 2003
Pages: 247

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