Linux – setuid, setgid and sticky bit

setuid ( or setguid)  permission on a file means that the file will run as the user (or group) of the file, not as the user who ran that file.

setguid -on directory means that files created in the directory will inherit the group affiliation from the directory, rather than inheriting it from the creating user. This is commonly used on group collaborative directories.

stickybit – mainly for directory as sets a special restriction on deletion of files: only owner of the file (and root) can delte files within the directory.

Special Permission Effect on Files Effect on Directories
u+s (suid) File executes as the user that owns the file, not the user that ran that file
g+s (sgid) Files executes as the group that owns the file Files newly created in the dir have their group owner set to match the group owner of the dir.
o+t (sticky) user with write permission on the dir can only remove files that they own, they cannot remove files owned by other users

number alias : suid (4) sgid (2) sticky(1)

When we implement these permissions ,we get the below symbols in permissions field :
–S—— SUID is set, but user (owner) execute is not set.
–s—— SUID and user execute are both set.
—–S— SGID is set, but group execute is not set.
—–s— SGID and group execute are both set.
——–T Sticky bit is set, bot other execute is not set.
——–t Sticky bit and other execute are both set.

Assign  suid to a File : # chmod  u+s testfile.txt OR #  chmod 4750  testfile.txt

SGID Example : # chmod g+s OR # chmod 2750 

StickyBit Example :  # chmod o+t /opt/ftp-data  or # chmod +t /opt/ftp-data OR # chmod 1757 /opt/ftp-data


reference : & Red Hat Sys Admin 1 (student workbook)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s