[K12OSN] chown script help needed (word of caution)

John Baillie jbaillie at stmarys-school.org
Tue Sep 13 22:55:24 UTC 2005


Quentin Hartman wrote:
> On Sun, 2005-09-04 at 12:49 -0500, Les Mikesell wrote:
> 
>>This will simply fail if one of the names contains spaces.
>>If you really don't want to do this to all the directories
>>under /home, you can generate the list some other way.
>>For example you could copy the /etc/passwd file, delete
>>the range you don't want, then (in vi) :%s/:.*// to
>>leave only the names.  If you save that in a file you
>>can change the 'for i in *' line above to
>>for i in `cat file`
>>to iterate over the list you want.
> 
> 
> A little one-liner I've used in the past to fix permissions only on
> "real" user directories and leave other stuff I tend to keep in /home
> alone is:
> 
> for i in `cat /etc/passwd | awk -F: '$3 > 500 {print $1}'`; do chown -R
> $i:$i $i; done
> 
> So maybe it's a one-and-half liner, but it eliminates the need (on my
> systems at least) to do manual file manipulations, and therefor also
> eliminates fat-finger syndrome. Let's hear it for stupid Unix tricks!
> 
Much better solution Quentin!
We keep a few non-user directories in /home and have moved  'em in and 
out when a need to adjust permissions arose.


John




More information about the K12OSN mailing list