Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A simple fix for incorrect Home folder ownerhsip problems Desktop
When backing up my "Home" directory before upgrading to a new hard-drive, I was unaware of the various Unix permissions that had to be conserved, in order to do this successfully. When reinstalling this backup into my newly reinstalled OS X 10.2.8 system folder on my new hard-drive, I found that most of my files and many of my applications were unusable. I had copied the backed up files using the Root account, and apparently this had changed all the permissions such that the files were now owned by Root, not by me!

A bit of frantic Unix research on a local Mac bulletin board followed (Revelation BBS, in Vancouver BC), where I found a tip contributed by Derek M. Warren, who came up with the following. This has (apparently) worked to restore full usability to my entire "Home" folder and files. In the Terminal app, type:
% sudo su  
% chown -R myname  /Users/myname  
The first line gives you root level access; the second line restores the correct ownership of the home folder. Replace myname with your actual short username, of course.

This seemed to work okay (fingers crossed!)

[robg adds: Some things to keep in mind -- Carbon Copy Cloner will create backups with permissions intact, and you might also be able to recover from something like this by running Apple's Restore Permissions (in Disk Utility), though I'm not sure it looks at ownership of the Users folder.]
    •    
  • Currently 2.67 / 5
  You rated: 2 / 5 (3 votes cast)
 
[10,820 views]  

A simple fix for incorrect Home folder ownerhsip problems | 16 comments | Create New Account
Click here to return to the 'A simple fix for incorrect Home folder ownerhsip problems' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A simple fix for incorrect Home folder ownerhsip problems
Authored by: garumph on Oct 14, '03 11:24:05AM

Argg! you are defeating the purpose of sudo! You changing to root to change to root.

Do it all on one line:

% sudo chown -R myname /Users/myname

When it asks for a password use you regular login password.



[ Reply to This | # ]
A simple fix for incorrect Home folder ownerhsip problems
Authored by: twalther on Oct 16, '03 03:39:49AM

I'm glad someone else posted this...

It drives me NUTS to see people experimenting with UNIX for the first time and coming up with things like "sudo su" for this purpose.

If you must run multiple instructions as root, for the love of god use "sudo -s" (opens a root shell by default) or "sudo tcsh" (or bash, zsh, etc).



[ Reply to This | # ]
A simple fix for incorrect Home folder ownerhsip problems
Authored by: clith on Oct 16, '03 11:37:36AM
f you must run multiple instructions as root, for the love of god use "sudo -s" (opens a root shell by default) or "sudo tcsh" (or bash, zsh, etc).
Or even just good old:
% su
Although I prefer using the "-" argument:
% su -
Which uses root's (probably more secure) login environment, not yours.

"sudo" is meant to do a one-line command as if you had run su, thus the name. And just f.y.i. (some people don't know) "su" stands for "super user". See? These cryptic Unix commands can all make sense! :-)

[ Reply to This | # ]

A simple fix for incorrect Home folder ownerhsip problems
Authored by: vajonez on Oct 17, '03 03:53:19AM
actually, su stands for substitute user or switch user. su, like sudo, can be used to switch to (or execute a command as) any user and not just root (the so-called super user). see man su and man sudo for more details.

[ Reply to This | # ]
psync
Authored by: SOX on Oct 14, '03 11:32:16AM

psync which I find useful at times has a facility for writing down permissions to a file for later restoration. I've found this very handy in cases where I am copying across files systems to remotely mounted disks. On the remote machine, my user ID may not exist or the group may not exist or rott may be squashed.
psync simply notes the permissions in a file which you can keep around until you restore the files in the proper file system.



[ Reply to This | # ]
psync
Authored by: clith on Oct 16, '03 11:38:52AM
Note that Carbon Copy Cloner uses psync.

[ Reply to This | # ]
A simple fix for incorrect Home folder ownerhsip problems
Authored by: DerekButterfield on Oct 14, '03 12:06:39PM

You could try copying all the permissions in the first place.

For example, I backup to a folder named My Files on my iPod:
sudo ditto -rsrcFork /Users /Volumes/iPod/My\ Files/Users



[ Reply to This | # ]
Warning
Authored by: Cantus on Oct 14, '03 12:57:50PM
The command presented in the hint will change the owner of your Home directory's folders to you, as it is by default.

However it will also change the owner of every file and folder within these folders. Unless you really are sure it's safe to do this, I would advise against performing such a radical change to your Home directory hierarchy.

Some files in your Home directory hierarchy are owned by other users (system, admin) and they need to have that owner set to properly work.

A much safer command to issue is the following that will only change the owner of those folders in your Home directory, leaving other files and folders within these folders untouched:

    chown username /Users/username/*


[ Reply to This | # ]
Warning
Authored by: Cantus on Oct 14, '03 01:09:58PM
Apparently this user had ALL of his files in his Home directory changed to be owned by root.

In this case, then the only way to work around this issue is to change the WHOLE Home directory hierarchy's owner so it is owned by you.

The command to be issued is this case is:

    sudo chown -R username /Users/username/*

However, caution is advised.

[ Reply to This | # ]

Warning
Authored by: gommino_2000 on Oct 14, '03 02:30:45PM

I don't understand why you suggest this. Every file and folder in your home directory should belong to you! A quick check on an another home directory (or a freshly created one) will confirm this.

I would also suggest changing the group to 'staff' at the same time with the following command:

% sudo chown -R myname:staff /Users/myname

Regards,
Rob.




[ Reply to This | # ]
Warning
Authored by: uochris on Oct 14, '03 08:51:54PM

Isn't the default to have the user as the owner with rwx across the board and the group is staff with no access. Why is there a group assigned if they have no access? With the command issued above, that would give all other admin users access to your folders which is not how the user folders are set up by OS X. Is that right or is my system funky?



[ Reply to This | # ]
Warning
Authored by: yellow on Oct 15, '03 09:42:34AM

It does place your home directory in the staff group. However, this wouldn't stop an admin from parusing your hierarchy, so changing the group to admin ensures that no non-admin users can paruse your hierarchy. Personally, on every machine I set up, the non-admins have thier home hierarchies chowned to username:staff, admin to username:admin, and Applications/Applications (Mac OS 9), System Folder are chowned to root:admin.



[ Reply to This | # ]
Warning
Authored by: gommino_2000 on Oct 15, '03 04:04:58PM

The command I have supplied merely sets the group to 'staff'. It does not alter the permissions in any way at all. To do that you use the 'chmod' command. Also, the 'staff' group is the group that all users, whether admin or normal, are in. Admin users are also added to the 'admin' group.

Rob.



[ Reply to This | # ]
RE: A simple fix for incorrect Home folder ownerhsip problems
Authored by: nick on Oct 14, '03 01:09:54PM

you still need this this hint when you copy your HOME-folder with CCC or psync if you change your username on the new machine.

afaik (correct me if i'm wrong.), even the order or in wich you create users matters. the user-IDs are stored as numbers beginning with 501. changing the creation-order will change the numbering.

get the sudo thing right (already mentioned above).

n.



[ Reply to This | # ]
nope. psync will work just fine
Authored by: SOX on Oct 14, '03 04:40:39PM

Psync will work just fine to restore users since it does not depend upon UIDs just the user name and group name. of course you have to be sure that your username and group name exist.



[ Reply to This | # ]
RE: A simple fix for incorrect Home folder ownerhsip problems
Authored by: JohnnyMnemonic on Oct 14, '03 06:50:00PM

Indeed, the first user created on a machine will have UID 501. The next will have 502, etc. You can change the UID of a user in NetInfo Manager, but that will naturally change permissions on files, too.

And, no, "Fix Permissions" will not correct this. "Fix Permissions" only corrects those permissions of items installed by the system installer (I am pretty sure), not anything installed or created by anything else.

I just use CCC at this point--awesome tool.

[ Reply to This | # ]