0

I have a folder called fruit with permission 777 and its owner is fruit.

I want to create a folder named apple under the fruit folder. But I want to set this folder's owner as apple, not fruit.

However, I have only access of the apple user.

As the fruit folder is set to 777, is it possible to do this using chgrp?

4

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.

  • seems same answer, same thoughts lol – Maythux May 21 '15 at 17:55
  • @Maythux yep, but you're faster :) well done. – apaul May 21 '15 at 17:57
3

The command chown needs root permission when transferring ownership to other users. chgrp is irrelevant since it only affects the group, not the user.

You can't obligate someone to take a file from you if he doesn't want. If you are a root or with root permissions then you are the commander and you can do whatever you want.

Instead as a workaround, you can create a group that held both user and give the ownership to that group so anyone of the users now has an ownership over it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.