How do I change group ownership on folders created by a specific user?
6,381
Use find
to do this:
find -type d -user $USER -exec chown :groupname {} +
it will finds all directories which belongs to the user $USER
and changes the group of them to groupname
.
- Note:
$USER
is the current user you can change it with your desired one.
Related videos on Youtube
Comments
-
Ukuser32 almost 2 years
I have
user
who has created a folder and so the permissions areuser:user
. I have now addeduser
togroup
so my question is how can I update all folders created byuser
, as if I'd donechown user:group
, but not all folders, because some have different owners. In effect - refresh folders to update the new group rights? Filezilla lists them still with the olduser:group
permissions.-
Zanna about 7 years
chown :group folder1 folder2 folder3
? What's wrong with that? -
Ukuser32 about 7 yearsMe being silly. I didn't know you could just use :group and didn't have to do user:group. I will leave this in case anyone else comes across it.
-
Ziazis about 7 yearsWhy use chown for just changing the group if there is an explicit command for that called "chgrp"?
-
-
muru about 7 yearsAnd I'd use the test for group ownership instead of user ownership (for cases like
user:group2
) (Also,-exec ... {} +
) -
Ravexina about 7 years@muru I didn't get your point :/ (find updated)
-
muru about 7 yearsRight now files are owned by
user:user
, but some, according to OP, have different owners (sayuser2:user
oruser:group2
). In that case, it'd make sense to only change:user
to:group
. -
Ravexina about 7 years@muru got it ;)