I accidentally the whole thing
drwxr-xr-x 4 imaan rayhawkpasscom 4096 May 9 14:59 imaan
drwxr-xr-x 4 kimessite rayhawkpasscom 4096 Mar 15 2011 kimessite
drwxr-xr-x 4 kineticimaging rayhawkpasscom 4096 Apr 4 15:56 kineticimaging
drwxr-xr-x 4 lynbrookmed rayhawkpasscom 4096 Jul 18 11:51 lynbrookmed
drwxr-xr-x 5 marcop rayhawkpasscom 4096 Sep 6 15:39 marcop
drwxr-xr-x 5 mesachiro rayhawkpasscom 4096 Sep 9 13:21 mesachiro
drwxr-xr-x 4 paramount rayhawkpasscom 4096 Jun 7 10:39 paramount
drwxr-xr-x 4 paramountco rayhawkpasscom 4096 Jun 16 13:50 paramountco
drwx------ 2 rayhawk rayhawkpasscom 4096 Jul 13 15:30 rayhawk
I mistakenly changed the groups of all these directories to an incorrect group.
The group name should be the same as the owner (3rd column) or the folder (last column)
Is there a way I can automatically chgrp
recursively based on owner/dir name?
From the directory in question, I'd run:
for i in *; do chown -R $i:$i $i; done
(The "-R" in chown, only if you initially did a recursive
chgrp
)This seems correct to me, but your YMMV and might sell your firstborn for organ donation, so be careful:
Use the either the group or gid option in find and make the change to the result from the find. Here is a example with listing directories owned by mySQL
In this case, you want to change the directories found to a different group user. In that case, you would do this:
If the directory name is different from the owner and you want to change group ownership based on the owner, try this: