Q: Fixing multiple Users permissions
Hey Everyone,
In a classroom environment after a month without issues all of the sudden everyone is getting locked out of their folders, including my local admin user.
What works logging into each user elevated, I may run terminal command:
sudo find ~ $TMPDIR.. -exec chflags -h nouchg,nouappnd,noschg,nosappnd {} + -exec chown -h $UID {} + -exec chmod +rw {} + -exec chmod -h -N {} + -type d -exec chmod -h +x {} + 2>&-
This is from Linc Davis Repairing permissions when owner is "Fetching..."
So how to use Apple Remote Desktop to fix this via UNIX script?
#! /bin/bash
cd /Users
# Create an array with a list of all users in the users folder excluding Shared, site, nc12, and g
full=$(ls -1 /Users/ | grep -v 'Shared\|site\|nc12\|g\|.localized')
echo Fixing Permissions....
# Loop permissions fix for the values of the array $full
for i in $full
{
cd /Users/$i
find ~ $TMPDIR.. -exec chflags -h nouchg,nouappnd,noschg,nosappnd ;
chown -h $UID
chmod -R -N ~ $i
chmod -R 700 $i
chmod -R 777 $i/Public
chmod -R 733 $i/Public/Drop\ Box
}
# A reboot shouldn't be necessary since the permissions change instantaneously and will be different the next time a program tries to access files.
# That said, it's never a bad idea to reboot
echo "You must REBOOT the machine to complete the process. Thank you."
exit
What may my syntax errors be? Other suggestions?
iMac, OS X Mavericks (10.9.5), null
Posted on Oct 13, 2015 4:23 PM