[Ilugc] Some doubts

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Sat Feb 16 12:26:12 2008

On 09:30:44 Feb 16, Gourav Shah wrote:

The file permissions bits include an execute permission bit for file owner, 
group and other. When the execute bit for the owner is set to "s" the set 
user ID bit is set. This causes any persons or processes that run the file 
to have access to system resources as though they are the owner of the 
file. When the execute bit for the group is set to "s", the set group ID 
bit is set and the user running the program is given access based on access 
permission for the group the file belongs to. The following command:

chmod +s myfile

sets the user ID bit on the file "myfile". The command:

chmod g+s myfile

sets the group ID bit on the file "myfile".


Cool. Thanks. I just read up a bit on this. Many thanks to Arun Khan for
correcting me on this.

I figured that the sticky bit behaves differently with files and
directories. Ditto with setuid/setgid. At least that is what wikipedia
tells me.

Apparently the sticky bit is a historical baggage that is no longer
relevant.

However when set on directories it is quite useful. The /tmp directory
usually has the sticky bit set.

Here is an excerpt from sticky(8) man page.

-----------------------------------------------------------------------------
STICKY FILES
     Historically, an executable shareable file which had the sticky bit set
     was not immediately discarded from swap space after execution.  The ker-
     nel hoarded the text segment of the file for future reuse, thus avoiding
     having to reload the program.  This is no longer true on modern systems;
     the current virtual memory system keeps track of recently used executa-
     bles, making the sticky bit for files redundant.  The sticky bit can
     still be set on files, but without any effect.

     Only the superuser can set the sticky bit on a file, though the owner of
     the file may clear the sticky bit.

STICKY DIRECTORIES
     A directory with the `sticky bit' set places restrictions on file dele-
     tion: a file in a sticky directory may only be removed or renamed by a
     user if the user has write permission for the directory and the user is
     the owner of the file, the owner of the directory, or the superuser.
     This feature is usefully applied to directories such as /tmp which must
     be publicly writable but should deny users the license to arbitrarily
     delete or rename each others' files.

     Any user may create a sticky directory.  See chmod(1) for details about
     modifying file modes.
-----------------------------------------------------------------------------

See ya,
-Girish

Other related posts: