I am learning about UNIX file permissions and I saw that on my Ubuntu system, /var/mail has the setgid bit set. Why is this?
$ ls /var/mail/ -dl
drwxrwsr-x 2 root mail 4096 Feb 23 05:57 /var/mail/
This book I'm reading says:
> Setgid is useful when you have groups of users who need to share a lot of files.
> Having them work from a common directory with the setgid attribute
> means that correct group ownership will be automatically set for new
> files, even if the people in the group don’t share the same primary
> group.
That description doesn't sound like anything useful for /var/mail since users don't directly manipulate that directory.
The files created in /var/mail end up with the group owner "mail", but doesn't this already happen? Only "mail" can create new files in the directory (and root).
The only useful case I can think of is when a sysadmin adds a new mail account with sudo touch /var/mail/
. That file would still have the "mail" group owner.
Asked by enoopreuse22
(31 rep)
Feb 25, 2023, 10:04 PM
Last activity: Mar 4, 2023, 08:10 PM
Last activity: Mar 4, 2023, 08:10 PM