Linux commands

Page: ()   1  2  3  4  5  6  ()

Command:

chown
Changes ownership of a file or set of files

http://www.opengroup.org/onlinepubs/9699919799/utilities/chown.html





Description of commmand / detailed explanation:
The chown and chmod commands are related in their function. The Chown command changes the ownership of the a file or groups of files (using the recursive command.)

This is an admin command, root user only can change the owner of a file or directory.

One can change both the owner and the group the file or directories belong to using the chown user.group file.txt syntax.
Command options:
-R Change the permission on files that are in the subdirectories of the directory that you are currently in.
-c Change the permission for each file.
-f Prevents chown from displaying error messages when it is unable to change the ownership of a file.




How to use it: chown [options] newowner.newgroup filename/directoryname



Typical Usage Examples:

  1. chown hiox test.txt

    The owner of the 'test.txt' file is root, Change to new user hiox.

  2. chown -R hiox test

    The owner of the 'test' directory is root, With -R option the files and subdirectories user also gets changed.

     

  3. chown -c hiox calc.txt

    Here change the owner for the specific 'calc.txt' file only.




Available in:

debian
fedora
gentoo
suse
mandriva
ubuntu
Related commands:

  • chmod
  • ls
  • chgrp
  • fchown

Page: ()   1  2  3  4  5  6  ()