Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I got into a good-natured spat with a fellow worker about the nature of the sticky bit.

My contention, working from the chmod man page was the the sticky bit, if set, allows only the owner to delete or rename files:

RESTRICTED DELETION FLAG OR STICKY BIT
The restricted deletion flag or sticky bit is a single bit, whose 
interpretation depends on the file type.  For directories, it prevents  
unprivileged  users from removing or renaming a file in the directory 
unless they own the file or the directory; this is called the restricted 
deletion flag for the directory, and is commonly found on world-writable 
directories like  /tmp.   For regular  files  on  some  older systems, the 
bit saves the program's text image on the swap device so it will load more 
quickly when run; this is called the sticky bit.

(see also:http://en.wikipedia.org/wiki/Sticky_bit)

My colleague is adamant that the authoritative answer is an article on a Yale forum from 1996 that instructs how the sticky bit is used to set the group inherited rights for the directory. (http://www.library.yale.edu/wsg/docs/permissions/sgid.htm)

Accordingly, I have installed setafcl and set acl as an option on mount (as detailed here: http://superuser.com/questions/264383/set-file-permissions-so-that-new-files-inherit-same-permissions .

Would anyone like to help settle this dispute... I believe I could drag a milkshake out of the guy if I am right.

Blake

share|improve this question

2 Answers 2

You and your colleague are talking about two different bits, so it's understandable that you don't agree on what they do.

The sticky bit, the setuid bit and the setgid bit are three distinct bits in a file's (or directory's) mode. See e.g. the chmod(2) man page.

You're both right, your reference for the sticky bit is accurate, your colleagues reference for the SGID bit is too.

share|improve this answer
    
So I guess the real question is which of these methods are correct for setting the directory group permissions so they are inheritable? –  user253962 Sep 13 '13 at 17:40
    
Depends what you mean by "inheritable". If you mean Windows/NTFS-type inheritance, ACLs are required (and I'm not too familiar with those), plain chmods won't help. If you mean files created take the group of their containing directory, then that's the SGID bit as indicated in the docs your colleague refers to. –  Mat Sep 13 '13 at 17:46

The setgid bit is what you would need.

sudo chmod g+s /foldername

Do not use the -R option for recursive unless you want to have the existing files in that directory/sub-directories to have the bit set as well. Usually you do not want the setgid bit on for files since the directory has it set.

Below is how to recursively set the gid bit on a folder and its sub-folders.

sudo find /foldername -type d -exec echo chmod g+s {} \;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.