Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to reset permissions for all user home dirs

Hello all,


Hope someone can help me with how best to approach this.


The home dirs permissions have been messed up by a restore of data. Users cannot log into clients for some reason. I have created a new home dir for an existing user which can now login whereas with his previous home dir could not. After checking the permissions on some home folders, it looks like the owner is missing (just blank).


I was going to use a terminal script to extract the username using dscl and then using this in a variable reset the home dirs. However, it gets a little more complicated in that the user homes are spererated into folders such as year7, year 8 etc). I have tried to extract the NFSHomeDirectory, again using dscl, but this is where I get stuck. My script allows me to pull in the first column of the array but I don't know how to edit the script to pull in the NFSHomeDirectory path into a 2nd array that can then be added to the chown script via a variable. Here is my script at the moment. $HomeDir is the variable that will hold the NFSHomeDirectory path.


#!/bin/bash

# userlist.sh


dscl /LDAPv3/127.0.0.1 -list /Users NFSHomeDirectory | awk '{print $1","$2}' > $PWD/Users.txt

UIDs=$PWD/users.txt


for name in $(awk 'BEGIN{FS=","}{print $1}' < "$UIDs" )


do


sudo chown -R $name $HomeDir

sudo chmod -R 700 $HomeDir


sudo chmod +a "$name allow list,add_file,search,delete,add_subdirectory,delete_child,readattr,writeattr,re adextattr,writeextattr,readsecurity,file_inherit,directory_inherit" $HomeDir

sudo chown -R $name:staff $HomeDir

sudo chmod -R ug+rwx $HomeDir


let "n += 1"


done

exit 0


Thanks in advance for any help.

Posted on Feb 17, 2013 5:19 AM

Reply
1 reply

Feb 17, 2013 4:09 PM in response to Newbie-2-macs

Assuming you have tried resetting the actual owner name on one of the homes with an 'unknown' user, and it works then it is a simple matter of changing the permissions. The application Passenger from MacInMind software has functionality built in to batch change permissions in directories. Its reliable and works slick! I have also used 'Server Cleanup" version 2 (10.3/10.4 servers) in the past to successfully repair home permissions. There is a vesion 3 that is for 10.5 server. You could give it a look and see if it is for you. Read all instructions and warnings on that one. http://www.gabrenas.org/ServerCleanup3.html

How to reset permissions for all user home dirs

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.