Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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[@]}"
share|improve this answer
    
Thanks to @Gordon Davisson for fixing my array syntax and finding a way around using find(1). I wasn't aware of chmod(1)'s capital-X notation. I added a -R back in that is needed if you're not using find(1). –  Spiff May 21 '10 at 18:48
    
That script looks great and works fine, Spiff. I also didn't know about capital X and that's great stuff! It's already easier using it than my current methods. But... I still hope someone can come up with an even more automated way, such as service (to do it with right click) or something drag n' drop, as to avoid the extra step of having to go to the dreaded Terminal. :) –  Cawas May 23 '10 at 5:45

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.