chown in Mac OS X

By: Strauss K Viewed: 153260 times  Printer Friendly Format    


Change file owner and/or group.

Syntax 
      chown [-fhv] [-R [-H | -L | -P]] owner[:group] file ...

      chown [-fhv] [-R [-H | -L | -P]] :group file ...

Options

   -R         Recurse: Change the mode of file hierarchies rooted in the files
              instead of just the files themselves.

   -R -H      Follow symbolic links on the command line
              (by default Symbolic links within the tree are not followed.)	       
   -R -L      All symbolic links are followed.
   -R -P      No symbolic links are followed. (default)
	     
   -f         Do not display a diagnostic message if chmod could not modify the
              mode for file.

   -h         If the file is a symbolic link, change the mode of the link
              itself rather than the file that the link points to.

   -v         Verbose, show filenames as the mode is modified*

The owner and group operands are both optional; however, at least one must be specified. If the group operand is specified, it must be preceded by a colon (:) character.

* The -v option is non-standard and its use in scripts is not recommended.

The ownership of a file may only be altered by a super-user for obvious security reasons.

Notes

Previous versions of the chown utility used the dot (.) character to distinguish the group name. This has been changed to be a colon (:) character so that user and group names may contain the dot character.

The -v option is non-standard and its use in scripts is not recommended.

The owner/group may be either a numeric ID or a name. If a user/group name is also a numeric user ID, the operand is used as a user name.

chown exits 0 on success, and >0 if an error occurs.

Examples

Assign Ursula as the owner of "MyFile.txt" file in the Shared directory.

$ sudo chown Ursula /Users/Shared/MyFile.txt

Assign Ursula as the owner, and staff as the group for everything in the "tmp" folder

$ sudo chown -R Ursula:staff /Users/Shared/tmp/



Most Viewed Articles (in macos )

Latest Articles (in macos)

Comment on this tutorial