linux: can a file/directory belong to a group which the owner doesnt belong to?

0

I read that "Your files and directories are owned by the group (or one of the groups) that you belong to. This is known as their "group ownership"."

But what if a file/directory belongs to a group which the owner doesnt belong to?

I have such files and dont know if i have to change the group and what could be the consequences.

user1338413

Posted 2012-11-29T11:33:31.073

Reputation: 103

I'd suggest unix.SE instead of superuser.SE. Maybe some Mod can move?

– Jonas Schäfer – 2012-11-29T11:38:30.637

sorry. i will overthink the next time where to put my question. – None – 2012-11-29T11:52:54.460

Answers

1

In general, owner and group are completely independent. Normally though, in your home directory, your files belong to your own group except if you need them to be shared with another group (you possibly also belong to). A common usecase is an environment where a webserver serves the users ~/public_html directory but does not run as root. You'd then share that directory by assigning it the group of the webserver (often called apache, www or httpd) and granting that group the permissions to read the directory (chmod g+rx).

If you have such files, it would be helpful to know where you have these and (if you know that) to whom the group which is set on these files belongs. If you decide to change that group to your own, you'll change the conditions under which the files can be accessed, which can lead to tasks failing due to Permission Errors or even opening these files for unauthorized access (if others have more privilegues than group).

Jonas Schäfer

Posted 2012-11-29T11:33:31.073

Reputation: 1 312

Your answer is far more complete than mine. – Sacx – 2012-11-29T11:39:26.353

0

Yes is possible. For example you can have the root user as owner and your group on a file. That doesn't mean root is in your group ...

Sacx

Posted 2012-11-29T11:33:31.073

Reputation: 126