Re: Misskey resulted in chown entire directory tree
On Sat, 29 Jan 2000, Pavel Epifanov wrote:
> On Mon, 24 Jan 2000, John Foster wrote:
>
> >=that the result is the changing of the owner/group of every file on my
> >=complete directory tree to a single username.groupname. Any Suggestions
> Please correct me if I missed one way.
I sent a suggestion privately to John. I probably should have sent it
publicly. So I am going to post it publicly now.
Note: This only works for user's home directories, and it will be
confused by original hard links.
For those who don't read awk, the password file is separated into
7 fields by colons. This program separates those fields, checks to
see if the field that contains the user's home directory contains
/home, then it recursively chowns all the files in that home
directory back to the proper user and group.
> > awk -F: '
> > {
> > user = $1
> > group = $4
> > home = $6
> > }
> > home ~ /^\/home\// {
> > cmd = sprintf( "chown -R %s:%s %s", user, group, home )
> > system( cmd )
> > }
> > ' /etc/passwd
> > Of course you would have to be root first.
Reply to: