chgrp
is to "change the group ownership of a file or directory". Thus, you can't change user ownership with that command (use chown
instead, which can change user and group ownership)
If your folder fruit
is in 777 mode, obviously, anybody can create a sub-folder inside it. This sub-folder will be owned by the user who created it, so in your case, the sub-folder will be owned by apple
.
Now, if your user apple
wants to change the group ownership of one of his files, he has to be a member of that group. See:
$ id apple
uid=500(apple) gid=500(apple) groupes=500(apple,fruit,banana)
Then user apple
could change his files or folders' group ownership to apple
, fruit
or banana
but not to cherry
since he's not a member of the cherry
group.