Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-16-2009, 04:42 AM   #1
LQ Newbie
Registered: Nov 2009
Posts: 5

Rep: Reputation: 0
Problem with SUID, SGID and Sticky Bit

Can anybody describe about SUID, SGID and Sticky Bit's function and how they work with files and directories. These things make me so confused . So if someone help me, that will be highly appritiated. And finally i am totally a in linux world ( My operating system is RHel5).
Old 11-16-2009, 08:20 AM   #2
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149

Rep: Reputation: 23
I believe "man chmod" or "info chmod" describes all that. If there are specific things you don't understand after reading that, I'm sure we can help clear them up.
Old 11-16-2009, 08:56 AM   #3
Registered: Jun 2009
Location: Penang, Malaysia
Distribution: Mageia, CentOS, Ubuntu
Posts: 468

Rep: Reputation: 72
Let me attempt to answer this one.

SUID is used mainly on executable files when you want whoever executes this file to have the permissions of the file owner (usually root). This is somewhat of a security risk & should be used with caution.

SGID is usually used on directories shared by GroupID. Where users join a group and share access to a directory using the GID of the directory. SGID is then used to ensure that all files created in that directory also belong to the same GID, allowing all group members access.

The Sticky bit is used on world writable directories to maintain ownership control. When a directory is world writtable, any file in it can be deleted by anyone. By setting the sticky bit on the directory, it will enforce ownership of the files & ensure that only the file's owners and root can delete the files. You can see an example of this in the /tmp directory.

Last edited by ongte; 11-16-2009 at 09:00 AM.
1 members found this post helpful.
Old 02-25-2010, 12:28 PM   #4
LQ Newbie
Registered: Sep 2009
Posts: 8

Rep: Reputation: 0
Question A further reference & question

@ongte: Thanks for giving a succinct and excellent reply to the sticky bit question. I found a helpful article by Wayne Pollock that went into more details if anyone wish to read further.

I have a question about the Sticky bit 't' bit applied to executable. For example, in this Tips for Linux

Sticky Bit

... Setting the sticky bit tells Unix that once the concerned application is executed, it should remain in memory. Remember that Unix is a multi-user OS and was mainly designed so that multiple users can work simultaneously. Thus the logic used is that a program that exists in memory requires lesser time to start when a new user requests for the same program. Thus when one user has just used a program and then a new user wants to use the same program, the second user doesn't have to face a time delay for the program to initialize itself. It would be readily available to him. The concept of the sticky bit was a very useful one, long back when fast disk access and other memory access technologies weren't around. But in today's age the concept of sticky bit is obsolete, since modern day technology is advanced enough to reduce the time delay while loading applications into the memory. Thus currently the sticky bit is of very little significance. Sticky bit is only associated with executables.
Notice where I underlined. We defintely see sticky bits used in non-executables now (as the /tmp example mentioned above). There is no date on this article. Is that quote inaccurate or just out date?

Also, can someone shed some light on the current status of the above quoted "sticky bit for executables"? Is it still implemented in modern kernel/systems? If so, which system?

I understand that it is not necessarily a good idea to use such "sticky executable feature" to mess with the kernel's ability to manage memory in a modern kernel. The question is just if the "feature" still there?

Thanks in advanced for any help.
Old 02-25-2010, 07:43 PM   #5
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,118

Rep: Reputation: 2669Reputation: 2669Reputation: 2669Reputation: 2669Reputation: 2669Reputation: 2669Reputation: 2669Reputation: 2669Reputation: 2669Reputation: 2669Reputation: 2669
As said above,
.But in today's age the concept of sticky bit is obsolete
for EXECUTABLES. What the prev poster said re /tmp dir is still true.
In a default RHEL install, its probably the only place you'll see it used.
Old 02-26-2010, 08:27 AM   #6
Registered: Jun 2009
Location: Penang, Malaysia
Distribution: Mageia, CentOS, Ubuntu
Posts: 468

Rep: Reputation: 72
As I understand it, the sticky bit for executables to remain resident in memory is not implemented in Linux. So this part of it really is quite obsolete.

But it's usage on directories for enforcing file ownership is still commonplace. In a sense, directories are just a special kinda executable file. When you execute it you go into that directory (Notice that you need to have execute permission to change into a directory).

So in sense I guess your underlined statement still holds true.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Significance/reason of using SUID, SGIDand Sticky bit ? tofee Linux - Newbie 3 08-22-2012 07:56 AM
what is "sticky bit mode" , "SUID" , "SGID" augustus123 Linux - General 10 08-03-2012 05:40 AM
SGID and SUID Paris Heng Linux - General 2 11-08-2008 10:45 PM
SUID and SGID ? Why don't they work ? tungvs Linux - Newbie 17 09-01-2008 07:36 PM
sgid and sticky bit levis_inferno Linux - Networking 5 06-01-2006 02:00 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:24 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration