# group permissions in Linux

**URL:** <https://boards.straightdope.com/t/group-permissions-in-linux/141787>\
**Category:** Factual Questions\
**Created:** [December 10, 2002, 5:13pm UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787 "2002-12-10T17:13:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![scr4](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@scr4](https://boards.straightdope.com/u/scr4)\
**Post date:** [December 10, 2002, 5:13pm UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/1 "2002-12-10T17:13:25Z")

</div>

It took me all evening to figure out that groups don’t work the same in Linux as in Solaris. You only belong to one group at a time, and you have to manually change the group using the **newgrp** command. Is that correct? What I want to know is, how exactly are you supposed to use this feature, and is there a way to belong to all groups? On my Solaris server I have HTML files owned by group **wwwadmin** , some setup files by **manager** , and specific software setup files assigned to different groups. Which means if I want to do various configuration changes from a Linux box I’ll have to keep doing a **newgrp**. This seems terribly inconvenient.

---

<div class="post-metadata">

**Author:** ![gazpacho](https://avatars.discourse-cdn.com/v4/letter/g/6f9a4e/32.png) [@gazpacho](https://boards.straightdope.com/u/gazpacho)\
**Post date:** [December 10, 2002, 5:42pm UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/2 "2002-12-10T17:42:08Z")

</div>

scr4,

I am not a linux guru but I just logged into one of the linux computers at work. When I type groups I get a list of groups so it seems to me that you can belong to more than one group on linux.

---

<div class="post-metadata">

**Author:** ![breaknrun](https://avatars.discourse-cdn.com/v4/letter/b/bbce88/32.png) [@breaknrun](https://boards.straightdope.com/u/breaknrun)\
**Post date:** [December 10, 2002, 8:09pm UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/3 "2002-12-10T20:09:55Z")

</div>

**scr4** , you are correct. You can belong to multiple groups but not at the same time. The id command will show your current group id and all the groups you can change to. When you need to access files owned by another group, you’ll need to newgrp to that group first. This is the usual behavior for most unix-like OSes.

**gazpacho** , the command lists what groups you have access to, in addition to your primary group, but you do not have those group permissions until you set your current group id to one of those groups.

---

<div class="post-metadata">

**Author:** ![Terminus\_Est](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/terminus_est/32/3087_2.png) [@Terminus\_Est](https://boards.straightdope.com/u/Terminus_Est)\
**Post date:** [December 10, 2002, 8:44pm UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/4 "2002-12-10T20:44:04Z")

</div>

Eh? I’m a member of several groups and happily edit files belonging to those groups. I’ve never had to use the newgrp command. In fact, I’ve never even heard about it until this thread. I’m using Debian GNU/Linux

---

<div class="post-metadata">

**Author:** ![gazpacho](https://avatars.discourse-cdn.com/v4/letter/g/6f9a4e/32.png) [@gazpacho](https://boards.straightdope.com/u/gazpacho)\
**Post date:** [December 10, 2002, 8:45pm UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/5 "2002-12-10T20:45:15Z")

</div>

**Breaknrun**  
What you are saying is different from my experience. Just now I looked at two files owned by someone else each with a different group ownership. Both files had owner read and group read permissions only. I did not have to use the **newgrp** command to read these files.

---

<div class="post-metadata">

**Author:** ![mnemosyne](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mnemosyne](https://boards.straightdope.com/u/mnemosyne)\
**Post date:** [December 10, 2002, 9:17pm UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/6 "2002-12-10T21:17:25Z")

</div>

My SO says

> [@](#):
>
> You belong to every group you belong to. No need to switch from group to group. If you type command “groups” it will show you all the groups you belong to. And to change the group of a file or folder, use the command “chgrp”. If you want to add yourself to a group, you will probably need ot be root, and use the command “addgroup”. This applies for Debian Linux and probably most other Linux distributions.

Me: You are such a geek

Him: Something wrong with that?

---

<div class="post-metadata">

**Author:** ![scr4](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@scr4](https://boards.straightdope.com/u/scr4)\
**Post date:** [December 11, 2002, 1:04am UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/7 "2002-12-11T01:04:07Z")

</div>

Thanks for the help. But I’ve done some further testing and on my system (RedHat 8) I definitely have to do a newgrp to access files belonging to different groups. Does this mean that the behavior is different for each distribution? Can I change it by recompiling the kernel or something?

---

<div class="post-metadata">

**Author:** ![burntsand](https://avatars.discourse-cdn.com/v4/letter/b/ba9def/32.png) [@burntsand](https://boards.straightdope.com/u/burntsand)\
**Post date:** [December 11, 2002, 2:13am UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/8 "2002-12-11T02:13:10Z")

</div>

You’ve just encountered RedHat’s annoying “feature” called User Private Groups. Unless you disable this when adding users, whenever you add a user, a new group is created with the group name matching the new username. The new user becomes the only member of the group. If you’re using the default umask, any files created by this user can only be read and written to by this user. You can’t do a chmod +rwx on the files; it won’t work. This is frustrating for those of us unfamiliar with this scheme.

Full details are available at: [http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/ref-guide/s1-users-groups-private-groups.html](http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/ref-guide/s1-users-groups-private-groups.html)

The idea is that you should set up a new group for every shared project or directory, e.g. a group called “devel” for developers. Then if you want any member of the devel group to have access to a directory called “source”, you set the gid bit on the “source” directory by going “chmod g+s source” and then “chgrp devel source/”. After you’ve done this, any file created in the source directory inherits the gid bit from the parent directory, and will be accessible to any member of the “devel” group - because the “devel” group owns the parent directory.

The RedHat site explains the full rationale better than I can.

Good luck.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [December 11, 2002, 2:21am UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/9 "2002-12-11T02:21:12Z")

</div>

I concur with what **burntsand** said. Pissed me off when I first had to use RedHat.

[Holy war]  
Gimme FreeBSD anyday 😉  
[/Holy war]

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [December 11, 2002, 2:49am UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/10 "2002-12-11T02:49:41Z")

</div>

My fellow geeks, I have passed legislation that outlaws BSD forever. The assault penguins will launch in five minutes.

---

<div class="post-metadata">

**Author:** ![Terminus\_Est](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/terminus_est/32/3087_2.png) [@Terminus\_Est](https://boards.straightdope.com/u/Terminus_Est)\
**Post date:** [December 11, 2002, 3:19am UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/11 "2002-12-11T03:19:38Z")

</div>

**burntsand** , Debian works like that by default. Each user is setup as his own group, and to make shared directories you do the _chmod_ trick as you described. But I still don’t have to run _newgrp_ just to get access to the shared files.

---

<div class="post-metadata">

**Author:** ![Some\_Guy](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Some\_Guy](https://boards.straightdope.com/u/Some_Guy)\
**Post date:** [December 11, 2002, 3:41am UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/12 "2002-12-11T03:41:21Z")

</div>

See, crap like that is why i run Slackware. It might not be the easiest to use, but at least everything’s out in the open.

---

<div class="post-metadata">

**Author:** ![scr4](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@scr4](https://boards.straightdope.com/u/scr4)\
**Post date:** [December 11, 2002, 5:33am UTC](https://boards.straightdope.com/t/group-permissions-in-linux/141787/13 "2002-12-11T05:33:49Z")

</div>

Hmm, somehow I managed to fix it so I don’t have to run _newgrp_ every time, but I’m not sure what exactly did it. Maybe I just needed log out and back in again, or maybe I needed to use the supplied tools to set up groups instead of editing /etc/group manually. Anyway thank you all for the help.

And thank you **burntsand** for the link about User Private Groups. If I understand correctly, the “private” groups are dummy groups which allow you to safely use umask=002, right? I guess that makes some sense.
