Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The sticky bit is represented by a t when you do ls -l. Its use is defined at http://www.unixguide.net/hp/faq/5.1.9.shtml. In general, it will stop the kernel from unloading the program from memory right after it's finished running (so subsequent runs of the program will be faster).
The setuid bit (s in the user column) allows an executable file, when run, to take on root privileges. You should only use this for programs designed to give up the privileges that they don't need right after they start.
The setgid bit (s in the group column) is the same as setuid, except that it takes on the root group permissions rather than the user. (In general, if you set setuid then you should also set setgid).
There are some differences in the concepts stated by 'rjlee'.
1) Sticky bit was used on executables in linux (which was used more often)so that they would remain in the memory more time after the initial execution, hoping they would be needed in the near future. But since today we have more sophisticated memory accessing techniques and the bottleneck related to primary memory is diminishing, the sticky bit is not used today for this. Instead, it is used on folders, to imply that a file or folder created inside a stickybit-enabled folder could only be deleted by the creator itself. A nice implementation of sticky bit is the /tmp folder,where every user has write permission but only users who own a file can delete them. Remember files inside a folder which has write permission can be deleted even if the file doesn't have write permission. The sticky bit comes useful here.
2) As of SUID or SetUID bit, the executable which has the SUID set runs with the ownership of the program owner. That is, if you own an executable, and another person issues the executable, then it runs with your permission and not his. The default is that a program runs with the ownership of the person executing the binary.
3) The SGID bit is the same as of SUID, only the case is that it runs with the permission of the group. Another use is it can be set on folders,making nay files or folders created inside the SGID set folder to have a common group ownership.
The sticky bit is represented by a t when you do ls -l. Its use is defined at http://www.unixguide.net/hp/faq/5.1.9.shtml. In general, it will stop the kernel from unloading the program from memory right after it's finished running (so subsequent runs of the program will be faster).
The setuid bit (s in the user column) allows an executable file, when run, to take on root privileges. You should only use this for programs designed to give up the privileges that they don't need right after they start.
The setgid bit (s in the group column) is the same as setuid, except that it takes on the root group permissions rather than the user. (In general, if you set setuid then you should also set setgid).
Something else to be aware of is that, these days, the "setuid" and "setgid" bits may well be ignored, with the system using more sophisticated, rule-based algorithms to determine when programs may obtain either elevated privileges or altered identities. A single bit is too-easily overlooked.
"Sticky" is a now-obsolete concept that is almost always ignored.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.