Terminal 101: Changing File Owner with Chown

What is File Ownership?

File ownership simply means the files that were created by a particular user. These files are therefore “owned” by that user. Users who do not own the files cannot edit them unless that user has super user privileges (and can run the “sudo” modifier on the edit command), or that user belongs to the same group as the file is assigned to.

Changing one File

If you only wish to change the owner of a single file, then we’ll use a specific command that is different from the recursive command for directories. Before you begin, however, you’ll need to know the shortname of the user you will be assigning the files to. This will be the name of the user’s home directory in the Finder.

Once you have this bit of information, you can issue the following command:

sudo chown -v username file

Replace “username” with the shortname of the user who will be assigned the files, and replace “file” with the path and name of the file to be assigned. Because we used the -v flag (for verbose mode), you will see the file and what changed printed to the command line.

Changing a group of Files

You may need to change ownership for a directory and all of the files and subdirectories contained within. You can easily do this by adding the recursive flag to the command, like so:

sudo chown -Rv username directory

Replace the “username” placeholder above with the shortname of the user who will be assigned the files, and replace “directory” with the path and name of the directory whose contents will be assigned to the user. Again, we used the -v flag in addition to the -R flag. This means that the command will output the files changed to the screen, so you can see exactly what happened.

Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author on Twitter.

TOPICS
Latest in Macs
A mockup of the possible Apple M3 Ultra logo
Performance isn't the only reason you should buy Apple's M3 Ultra Mac Studio - it's reportedly one of the most power-efficient processors too
Mac Studio on a desk
Apple Mac Studio (M3 Ultra): the ultimate creative workstation
Mac Studio from above.
New benchmark suggests Apple's M3 Ultra may not be much faster than the M4 Max - only a minor uplift in multi-core performance
Apple Mac Mini on wood desk
Forget President’s Day sales, Apple is selling an M2 Mac mini refurb for just over $300 which could be the PC bargain of the year
Sergii Figurnyi
Apple's M5 chip is rumored to be in mass production - but we're still waiting for M4 MacBook Airs
A hand holding up the new Mac mini M4
Apple's M4 Mac mini might be one of the best Macs ever, but it has a serious issue that needs fixing right now
Latest in How Tos
Leaving Neverland 2: Surviving Michael Jackson
How to watch Leaving Neverland 2: Surviving Michael Jackson online and from anywhere, start time
Keith Hunter Jesperson (Dennis Quaid) sits opposite his daughter Melissa Moore (Annaleigh Ashford) in a prison visitation room in Happy Face
How to watch Happy Face online from anywhere – stream TV adaptation of hit podcast
AUSTIN, TEXAS - NOVEMBER 16: Ricardo Pepi #9 of the United States celebrates scoring during the second half of a Concacaf Nations League Quarterfinal Round leg 1 match against Trinidad and Tobago at Q2 Stadium on November 16, 2023 in Austin, Texas.
USA vs Panama live stream: watch CONCACAF Nations League semi-final 2025 online for free
Trinity Rodman #2 of the Washington Spirit crosses the ball during a game between Bay FC and Washington Spirit at Audi Field on November 10, 2024 in Washington, DC.
National Women's Soccer League 2025: How to watch NWSL games live from anywhere
AMD Radeon RX 6000 Series Graphics Card on top wooden desk beside a keyboard
How to update AMD GPU drivers
tiktok
How to edit TikTok videos