Home OS X
OS X Syntax

chown

Change file owner and/or group.

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

You can specify owner or :group or both owner:group 

KEY

   -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     Force, do not display a diagnostic message if the operation fails.

   -h     If the file is a symbolic link, the user ID and/or the
	  group ID of the link itself.

   -v     Verbose, show filenames as the owner is modified.

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

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

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.

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/

"I never, ever say "I can't" about anything. I might say "I don't have the authority to make that decision" or "Building A is too heavy for me to lift" or "I will need training before I pilot that space shuttle." - Mike Huber

Related commands:

chflags - Change a file or folder's flags.
chgrp - Change group ownership
chmod - Change access permissions
install - Copy files and set attributes
ln - Make links between files (hard links, symbolic links)
mount - Mount a file system
umask - Users file creation mask

Equivalent BASH command:

chown - Change file owner and/or group.




Back to the Top

Simon Sheppard
SS64.com