I know how setgid works, but I don't know why it is designed, is there any example to illustrate what problems it solves?
|
feedback
|
|
While a setgid file/binary might not be obviously useful I definitely find the setgid bit very useful applied on directories. Assuming you are parts of different working groups, which each has their own unix (permission) groups. Surely you would then want to put the setgid bit on project folders, making sure that the right group ownership is applied when you create new files, and thereby allowing your colleagues in that project group access to those files? | |||||||||
feedback
|
|
The main use is to preserve the group owner of a tree of files:
This tends to be useful in environments where different users will be creating/editing files/dirs under a directory: When all files/dirs share the same group, all users can edit/change the files/dirs (permissions permitting): This avoids situations such as "xyz owns file abc, so I can't edit it". An alternative to using setgid in this way is the grpid filesystem mount option. From man mount:
When enabled, files/dirs created on a grpid mounted filesystem also inherit the group of the parent directory:
I've found using grpid option appropriately reduces the chance for human error (since the filesystem does the work, regardless of dir permissions). | |||
|
feedback
|
|
To know more about setgid,setuid and sticky bit, check bellow link | |||
|
feedback
|