Change file owner and/or group.

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

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


   -R         Recurse: Change the mode of file hierarchies rooted in the files
              instead of just the files themselves.
              Take care to not run recursive chown on the root '/' directory or any other system directory.

   -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 (:)

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

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

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 can contain the dot character.

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

The owner/group can 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.


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/

Change the owner of only the hidden files (prefixed with .) in the folder Work:

chown -R .* goes up as well as down
sudo chown -R audrey /Work/.*
Will be expanded by the shell to:
sudo chown -R audrey /Work/. /Work/.. /Work/.bash_history

In other words chown -R audrey /Work/.. is equivalent to chown -R audrey /
Which we do not want!

The correct way to set this:

sudo chown -R audrey /Work/.[^.]*

Reset the permissions on the entire home folder for the currently logged in user ($USER) this will reset the user ID number (UID) for all files. POSIX file permissions only use the UID, not the UserName or GUID.

$ sudo chown -R $USER ~$USER

“To me, constructive criticism is when people take ownership of their ideas. That's why I don't listen to anything that's anonymous. But it's hard; when there's something hurtful out there, I still want to read it over and over and memorize it and explain my point of view to the person” ~ Brene Brown

Related macOS commands

chflags - Change a file or folder’s flags.
chgrp - Change group ownership.
chmod - Change access permissions.
umask - Users file creation mask.

Copyright © 1999-2024
Some rights reserved