How Should I Correct the Owners and Permissions in an OS X User Folder?
My issue is that I've seriously busted all of the owners and permissions on my user folder and subfolders and it's causing lots of issues using lots of applications.
The initial cause was that I had renamed a user by following the Apple support instructions at http://support.apple.com/kb/HT1428
After the new user was set up, Mozy backup wouldn't backup any more and lots of my applications couldn't update themselves automatically. The application usually started working again if I deleted the offending program and reinstalled it. I thought it was because the permissions were wrong and I found some places where GetInfo indicated that permissions were referencing the old user. Sometimes the dialog just said "Fetching" for the username and never updated to anything else.
I ran Onyx "fix permissions" and Disk Utility "Repair Permissions" with no results. With "Repair Permissions", it keeps throwing some info warnings about unexpected ACLs, but the info I could find online didn't think those would be causing issues like this.
I tried to recursively run some command line scripts on the user folders (both logged in as root and using sudo). chmod got lots of errors about the owner of the files being wrong. chown after that gave me other errors (I can't remember exactly what they were). In a fit of panic, I right-clicked the entire user folder and chose to apply it's permissions to all children.
From what I can tell, when I did that, I set everything to Read&Write for that user and Read-Only for "everyone" and "staff". Now, I'm worse off than before. Firefox crashed and it can't even update it's own settings so it brings up the "Do you want to restore these tabs" every single time it launches, even after repeatedly saying "Start New Session".
Basically, everything in my user folder is broken with regards to owner and permissions and I need to know what they are supposed to be. Who is the owner of the files in each directory supposed to be (Downloads, Applications, etc.) and what should the permissions be? Given those permissions and owners, what is the best way to go about setting those all right?
I saw a question similar to this at Resetting user permissions to their default mode but it only addresses permissions, not owners, which has been an issue already.
I'm not sure if reinstalling the OS over the copy I have right now would fix anything and I'm close to calling Apple Support if I can't figure anything out in the next few days. Thanks for any help.
Solution 1:
The first step I would recommend is to try resetting your home folder permissions with the Reset Password utility in Lion Recovery. (Despite the name of the utility, you won't actually be resetting any passwords.)
Resetting the home folder permissions with the Reset Password utility will reset both the owner and the permissions.
Restart your Mac holding ⌘+R to boot into Lion Recovery, which will bring you to the Repair Utilities screen.
Open Terminal from the Utilities menu.
In Terminal, enter
resetpassword
to open the Reset Password utility.Choose your hard drive icon at the top, then choose your user from the drop-down menu below. Do not reset the password here.
At the bottom of the window, under "Reset Home Directory Permissions and ACLs", click the "Reset" button. This may take awhile if you have a lot of files in your home folder.
This should solve your permissions problems for most apps. However, it's possible you may have a few apps which had saved files with special permissions that are different from the user's default permissions (like preferences or application support files). For those apps, you may need to delete their preferences or reinstall the app.
If resetting your home folder permissions doesn't work, then you may need to try restoring from a backup or transferring your data to an external drive.
Solution 2:
Run this
cd $HOME
{ sudo chflags -R nouchg,nouappnd ~ $TMPDIR.. ; \
sudo chown -R $UID:staff ~ $_ ; \
sudo chmod -R -N ~ $_ ; \
sudo chmod -R 755 ~ $_ ; \
sudo chmod 700 Desktop Documents Downloads Dropbox Library Movies Music Pictures Sites $_ ; \
sudo chmod 777 Public ; \
sudo chmod 733 Public/Drop\ Box ; \
} 2> /dev/null
Solution 3:
Your issues are basically the same. There is no standard for permissions for files in your home directory they all depend on their use.
Fixing permissions apps and scripts and OS installs should not affect the user area at all except maybe changing the permissions on the home directory. OS installs and most fix permissions scripts compare the permissions and owners to what is required for a clean install and this has no normal users. If they did I would consider this as a major bug.
The fix is to change the owner of the files ie use of chown on your home directory. The owner should be the new owner name.
There is no general way of getting permissions back as individual files depend on there application and all apps can be different.
Thus the only way is to restore from a backup before the change - do the change as per Apples notes and then chown all the files. Or look at each individual file and work out what permissions it should have - for most files your home directory this should be read/write for the owner and nothing (or read only ) for others. Directories will also need execute permission so that they can be listed. Applications will need other permissions.