[X-Unix] Recursive one-line chmod

Alexandre Gauthier supernaut at underwares.org
Wed Sep 21 11:08:12 PDT 2005


Phillip Burk <philburk at mac.com> a écrit :

> Alright, I'm trying to use ARD to issue a one-line command that will  
> step through all the directories in /Users and assign recursive  
> proper ownership.  I don't care if it errors on the Shared folder, I  
> have a login hook to blast that to 777.  I have no clue as to the  
> proper syntax of the thing although if I were using a script to do  
> this I imagine it would use a foreach command to parse the usernames  
> from the individual directories themselves and then assign ownership  
> based on that username.

Can't you push a bash script?

If you can, well, do this...
################################


#!/bin/bash

for i in `find /home/* -type d -maxdepth 0 | awk -F "/" '{ print $3; }` ; do
	if [ $i = "Shared" ] ; then
		echo "Shared folder. Skipping..."
	else
		echo "Setting owner of $i to its relevant user...
		# This is probably not netinfo friendly.
		chown -R $i:admin /Users/$i
	fi
done


########################

Do take note that I wrote this in 3 minutes, did not test it and
probably used flawed logic, but this does what your example did.
Vaguely.

Its probably not the best way to do this, and doesn't even takes in
account netinfo. I have no clue if chown should be changed for something
more relevant -- but if you can do bash, this should get you started,
just change the command.

DO NOT LAUGH AT MY POOR BASH SKILLS :'(


>
> Kinda like this:
>
> Foreach directory in /Users
>     assign name to $username
>     if $username=="Shared" then next
>     endif
>     chown -R $username:admin /Users/$username
>
> or something like that.  I'm not a programmer, heck, I'm not even a  
> shell-scripter.  I just need a little push with the syntax.  If I  
> have to push and run a script remotely to do this I'll do that.
>
> Thanks.
> _______________________________________________
> X-Unix mailing list
> X-Unix at listserver.themacintoshguy.com
> http://listserver.themacintoshguy.com/mailman/listinfo/x-unix
>
> Listmom is trying to clean out his closets! Vintage Mac and random stuff:
>         http://search.ebay.com/_W0QQsassZmacguy1984
>



--------------------------------------------------------------
Underwares.org -- Free Obscure IT knowledge Open Database.
Search fo knowledge: http://www.underwares.org/zcgi/contents



More information about the X-Unix mailing list