Untitled Document
chown Command

The chown command stands for Changing File Owner . chown transfers ownership of a file to a user , and it seems that it can optionally chnage the group as well . The command requires the users id ( UID ) of the recipient , followed by one or more filenames.

   chown options owner [:group] files(s)

Changing ownership requires superuser permission , so let's first change our status to that of superuser with the su command .

   $ su
   Password : ********
   # _

On succcessfull login you will see # prompt of super user .

1. Basic Example -

Run below command to change the ownership of file from user sharma to mangesh using chown , in following way .

   chown mangesh emp.csv

Once the ownership of the file has been given to mangesh , the user file permission that previously applied to sharma now apply to mangesh .Thus , sharma can no longer edit emp.csv since there is no write privilege for group and others . He can't get back the ownership either . But he can copy the file to his own directory , in which case he becomes the owner of the copy .

2. Changing File owner recursively ( -R ) option -

Run below command which Recursively grant ownership of the directory /output/files, and all files and subdirectories, to user mangesh.

   chown -R mangesh /output/files
Untitled Document