How to Change File Ownership in Mac OS X
Though it’s somewhat rare to encounter ownership and permissions errors in Mac OS X, it can happen, particularly when an account has been moved, or a files owner has been modified by a third party application. Oftentimes you can just run through the process to repair user permissions, but that’s not always guaranteed to sort out a problem, and in some situations you need to adjust a files ownership directly on either a single document or a group of files before the intended user will regain proper access to the file. For these situations, there are two ways to manually change a files ownership, through the Finder and also through the command line. We’ll cover both, though for more advanced users the chown command is really much faster, and in some respects, it can be easier too.
Changing a Files Ownership through Finder in Mac OS X
You can change a files ownership through the same Get Info panel that lets you adjust permissions in the Mac OS X Finder:
- Select the file in the Finder, then hit Command+i to summon the “Get Info” window
- Click the arrow alongside “Sharing & Permissions” to reveal the ownership and permissions options
- Select the lock icon to unlock preferences
- Click the [+] button to add a new owner, then add the user from the list and choose “Select”
- Now select the name and click the gear icon, selecting “Make (username) the owner”
While going through the Finder is undoubtedly easy, it’s still several steps long and the Terminal can be faster in many ways. Don’t be intimidated by a command prompt, we’ll walk through the process and as you’ll see it’s actually pretty simple.
Change File Ownership with chown from the Command Line
Using the command line is generally considered more advanced, but for some situations it’s not only faster than going through the graphical interface, but in some regards it’s easier too. Here we’ll walk through the basics of changing file owners through the ‘chown’ command, which is standard in Mac OS X and also nearly all variations of unix.
Launch Terminal from /Applications/Utilities/ to get started.
The syntax in it’s simplest form is:
chown [username] [file]
For a usage example, to change the ownership of a file named “test-file.txt” to the user “Bob” the command would be:
chown Bob test-file.txt
Keep in mind that the user name you’re looking to use is the account short name, which is usually what a home directory is named after. If you’re not sure what the short user name is, type ‘whoami’ into the terminal to get the current short name, or type “ls /Users” to see a list of all user accounts on the current Mac.
If you’re altering a system files ownership or another users files that you don’t have read and write access to, you can always proceed chown with ‘sudo’ to use chown as super user and force the change:
sudo chown bob ~/Desktop/test-file.txt
Typically you won’t need to change the group of a file, but you can do that with chown as well by appending it to the desired username with a colon like this:
sudo chown bob:staff ~/Desktop/test-file.txt
Again, you usually won’t need to change the files group, though occasionally you will run into a file that has somehow lost or misappropriated both it’s owning user and the access level group it once belonged to.
In Mac OS X, the group is usually either ‘staff’ for general user files that are not admin level, ‘admin’ for administrative level user files like applications, preferences, and connected drives, and ‘wheel’ for superuser access to core OS components like /bin, /library, /home, /etc, /usr/, etc
Anyway, use whichever method is right for your needs, but for almost all cases of adjusting file ownership these days I launch the Terminal and use chown. That’s mostly a matter of preference, but I’ve never been a giant fan of the Get Info panels handling of ownership, though it’s usually fine for making quick adjustments to permissions.