Live data from Hacker News

How do groups work on Linux?

jvns.ca

1–10 of 68 posts

Re: How do groups work on Linux?

#2
One of the most useful group-related tricks (introduced in BSD Unix, I believe) is the setgid bit on a directory. If this is set, new files and subdirectories created within the directory will have the same group as the directory, rather than the group of the process that created them.

Re: How do groups work on Linux?

#3
I absolutely love Julia Evan's writing. I find her articles / zines to cover interesting and useful technical topics while remaining _extremely_ accessible to me (especially when I was a student)! I really admire her ability to present technical topics in plain language.

Re: How do groups work on Linux?

#5

One of the most useful group-related tricks (introduced in BSD Unix, I believe) is the setgid bit on a directory. If this is set, new files and subdirectories created within the directory will have the same group as the directory, rather than the group of the process that created them.

I use this as a basic indicator of someone's Unix competency. Not as a straight binary thing, but if I'm talking to someone (interviewing or maybe debugging something) I've found that if you know about setgid/setuid you have probably been interested enough to know what you are doing.

Re: How do groups work on Linux?

#6

One of the most useful group-related tricks (introduced in BSD Unix, I believe) is the setgid bit on a directory. If this is set, new files and subdirectories created within the directory will have the same group as the directory, rather than the group of the process that created them.

  [dozzie@zorn /srv]$ ls -ld foo
  drwxrwxrwx  2 root  wheel  uarch 2 Nov 21 12:57 foo/
  [dozzie@zorn /srv]$ touch foo/nabla
  [dozzie@zorn /srv]$ ls -l foo/nabla
  -rw-r--r--  1 dozzie  wheel  uarch 0 Nov 21 12:58 foo/nabla
  [dozzie@zorn /srv]$ id
  uid=1001(dozzie) gid=1001(dozzie) groups=1001(dozzie)
  [dozzie@zorn /srv]$ uname -s -r
  FreeBSD 11.0-RELEASE-p1
This is called "BSD semantics". You can get the same behaviour with appropriate mount option for Ext2/3/4 and XFS.

Re: How do groups work on Linux?

#7
post #6

One of the most useful group-related tricks (introduced in BSD Unix, I believe) is the setgid bit on a directory. If this is set, new files and subdirectories created within the directory will have the same group as the directory, rather than the group of the process that created them.

[dozzie@zorn /srv]$ ls -ld foo drwxrwxrwx 2 root wheel uarch 2 Nov 21 12:57 foo/ [dozzie@zorn /srv]$ touch foo/nabla [dozzie@zorn /srv]$ ls -l foo/nabla -rw-r--r-- 1 dozzie wheel uarch 0 Nov 21 12:58 foo/nabla [dozzie@zorn /srv]$ id uid=1001(dozzie) gid=1001(dozzie) groups=1001(dozzie) [dozzie@zorn /srv]$ uname -s -r FreeBSD 11.0-RELEASE-p1 This is called "BSD semantics". You can get the same behaviour with appropria…

What filesystem was that? And why is this behavior filesystem-specific?

Re: How do groups work on Linux?

#8
post #6

One of the most useful group-related tricks (introduced in BSD Unix, I believe) is the setgid bit on a directory. If this is set, new files and subdirectories created within the directory will have the same group as the directory, rather than the group of the process that created them.

[dozzie@zorn /srv]$ ls -ld foo drwxrwxrwx 2 root wheel uarch 2 Nov 21 12:57 foo/ [dozzie@zorn /srv]$ touch foo/nabla [dozzie@zorn /srv]$ ls -l foo/nabla -rw-r--r-- 1 dozzie wheel uarch 0 Nov 21 12:58 foo/nabla [dozzie@zorn /srv]$ id uid=1001(dozzie) gid=1001(dozzie) groups=1001(dozzie) [dozzie@zorn /srv]$ uname -s -r FreeBSD 11.0-RELEASE-p1 This is called "BSD semantics". You can get the same behaviour with appropria…

While it’s nice to have it as default behavior when it makes sense, it’s also nice to have setgid as an option rather than the rule.

Re: How do groups work on Linux?

#9
Some highlighted words do not appear using Firefox 57 on my Ubuntu 16.04.3, like the word "julia" at the third line. It's OK with Chromium.

EDIT: Seems a Firefox related bug, i noticed this strange behavior with other websites inc. Stack Overflow since then. Will investigate asap.

Re: How do groups work on Linux?

#10
post #7
post #6

Earlier quoted context omitted.

[dozzie@zorn /srv]$ ls -ld foo drwxrwxrwx 2 root wheel uarch 2 Nov 21 12:57 foo/ [dozzie@zorn /srv]$ touch foo/nabla [dozzie@zorn /srv]$ ls -l foo/nabla -rw-r--r-- 1 dozzie wheel uarch 0 Nov 21 12:58 foo/nabla [dozzie@zorn /srv]$ id uid=1001(dozzie) gid=1001(dozzie) groups=1001(dozzie) [dozzie@zorn /srv]$ uname -s -r FreeBSD 11.0-RELEASE-p1 This is called "BSD semantics". You can get the same behaviour with appropria…

What filesystem was that? And why is this behavior filesystem-specific?

Not what filesystem, it's what OS. FreeBSD. And ZFS, but UFS works the same.
Post reply on HN