Fixing mac user file permissions, not the system

Usually those files get wrong permission when coming from the network, even when I copy them from it, but mostly through "file sharing". So, definitely not talking about Disk Utility repair here, please.

But regardless of how the file got wrong permission, I know of two bad ways to fix them. One is CMD+I and the other is chown / chmod. The command line isn't all bad but isn't practical either.

Some times it's just 1 file I need to repair, sometimes it's a bunch of them. By "repair" I mean 644 for files, 755 for folders, and current user:group for all of them.

Isn't there any app / script / automator out there to do that?


Here's a script for you. I haven't tested this, so I'm going to set this Answer as a community wiki so others can fix my errors and infelicities.

#!/bin/bash

# Description: Fix file permissions like Cawas likes.

# TFILES is an array of target files.
TFILES=("$@")

# TUSER is the target user you want the files to be owned by
TUSER=$(id -u)

# TGROUP is the target group you want set on the files
TGROUP=$(id -g)

# chown everything to user:group:
sudo chown -R ${TUSER}:${TGROUP} "${TFILES[@]}"

# chmod to 644 for files, 755 for directories
sudo chmod -R u=rwX,go=rX "${TFILES[@]}"

Repair Permissions Lion, ML &c via their hidden feature

In Lion, ML, Mavericks... repairing permissions with Disk Utility, as is usually done, does NOT repair User file permissions.

Using a hidden feature by following the steps below will repair permissions does a better, more thorough job, and often fixes strange issues:

  1. Restart, and immediately upon hearing the chime, hold down Command+R to access the 'OS X Repair partition' utilities in Recovery mode.
  2. Now at the 'Repair Utilities' screen, click the 'Utilities' item in the Menu Bar. [[ Iff disk encryption's used, quit Mac OSX Utilities; at the prompt for 'Startup Disk' unlock it with the password. Then run the Terminal app. ]]
  3. Scroll down to find the Terminal application and double-click it to launch it.
  4. When its Terminal window opens, carefully type resetpassword within this windowand and then hit the Return key.
  5. The 'Password Reset Utility' window launches, (but resetting the password is not the point and so won't be done).
  6. Click Mac’s hard drive icon at top-left, and within the drop-down menu, select the user account experiencing issues.
  7. Then find at the bottom of the 'Password Reset Utility' window the 'Reset Home Directory Permissions and ACLs' button —> click it.

    Within a few minutes this reset process finishes, and then quit each open program. and then click 'Restart.' This fixes many problems related to the User, Home folder items, and the like.

This “Reset Home Directory Permissions and ACLs” technique works for previous OS X versions by use of the original OS X Install DVD.