1

It may be a stupid question, but I don't understand a detail about the command chown. I haven't found any explanation for this detail yet, maybe because it's so obvious to everyone.

When you change a file ownership, you can set a user parameter and a group parameter, using the following basic syntax:

chown <username>:<groupname> <filename>

This syntax allows you to insert into the field a user which belongs to a certain group, and to insert into the field a group. When I learned about the chown command for the first time I thought the groupname must be the same as the user group. But then I found out that the groupname can refer to a different group from the one the user belongs to.

Does this mean that you can set ownership to a user and a group, with the group being unrelated to the user group? If yes, it seems to me that this issue conflicts with what I found here. Or am I just getting confused?

Thank you!

1
  • 1
    In what way does it conflict with what you are reading in that other Q/A? A file is created with the ownership of the user+group that created the file. You may then change the owner and group with chmod.
    – Kusalananda
    Commented Nov 9, 2022 at 11:50

1 Answer 1

0

The "conflict" in your link refers to a non-root user. Non-root users can only change the group of a file to a group he belongs to (due to the reasons mentioned there).

However, root himself could set any user and any group to any file, and the owner of the file doesn't have to belong to the group. So there's no conflict.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .