Mass Permissions Change - CHOWN--??

smillin

Registered
I have about 1200 users who's home folder permissions got reset. The "owner" is now blank.

I need a way of using chown to pull the username and then apply that username as the owner of the folder. For instance:

/Volumes/Stu2Data/2012Students/%USERNAME%

All usernames are a listing of numbers.

So, the command would be "chown -R 120001 120001". Since I need to do this for 1200 users, is there a way to pull the username of "120001" and apply that user as the owner for the folder named "120001".

Does this make sense, it's kind of hard to explain?

Thanks for your assistance!

-Shane
 
Are these 1200 accounts on 1200 Macs?
Or, are all accounts stored on a server, and users log in through a network connection?
If so, this should be much easier to accomplish through whatever utility that you use to setup and maintain those accounts...
 
Are these 1200 accounts on 1200 Macs?
Or, are all accounts stored on a server, and users log in through a network connection?
If so, this should be much easier to accomplish through whatever utility that you use to setup and maintain those accounts...

They are all on the network. On a NAS connected to the student server. The directory is something like this:

/Volumes/Stu2Data/2012Students/120001
/Volumes/Stu2Data/2012Students/120002
/Volumes/Stu2Data/2012Students/120003
/Volumes/Stu2Data/2014Students/140001
/Volumes/Stu2Data/2014Students/140002
/Volumes/Stu2Data/2014Students/140003
...
...
...
 
Is Server Admin not working?

Is that all your user accounts, or just a subset of the total?
Have you found the cause for an unintentional permissions change of 1200 accounts?
 
Is Server Admin not working?

Is that all your user accounts, or just a subset of the total?
Have you found the cause for an unintentional permissions change of 1200 accounts?

That's just a subset of all of them. I think the cause of the unintentional permissions change was me unmounting the home dir NAS and running disk utility on it. I'm not going to go through 1200 students and drag in their user name as the owner. That would take me all week, haha.

There has got to be a way to use "chown -R %USERNAME% %HOMEDIR%" in a script.
 
This is all pseudo-code, but it would work, depending on which scripting language you like to use (bash, php, ruby, python, etc.):

1) Make a text file with each student's identification string/username, one per line. Should be able to export something like this out of AD or OD.

2) In the script, run a loop that reads a line from the file, stores the string in a variable, then concatenates a command that runs chown properly on the proper directory

3) Execute the command

4) Read the next line from the file

If you're not familiar with command-line scripting, I'm sure someone here would be willing to help you write a simple script to do this, provided you tell them which scripting language you'd like to use.
 
Back
Top