Once upon a time, suvayu ali fatkasuvayu+linux@gmail.com said:
However I failed to find how to see whether any of those bits are set for a file. I tried `ls -l ' in /bin, /usr/bin, and /tmp but didn't notice anything obvious. I also failed to find any appropriate option for ls to list it either. Am I looking in the wrong place?
Run "ls -ld /tmp" and you should see:
drwxrwxrwt. 17 root root 4096 2010-04-23 14:37 /tmp
The "t" at the end (instead of a normal "x") indicates the directory sticky bit.
Also in what situations would seting the setuid or setgid bits help? I could think of some, like writing configuration files for the application which are otherwise owned by someone else, maybe for a web server or a daemon or maybe some automated backup solution. Are these valid scenarios?
You should only have setuid/setgid for programs that are designed for privilege escalation (such as /bin/su and /usr/bin/passwd). Setting them on arbitrary programs is a security problem (since you could be giving any user the ability to do random things as another user, possibly root).