Skip to content

Files Permissions

JayBeeDe edited this page Jan 6, 2024 · 1 revision

Digital Representation of setuid, setgid and stick bits

Octal digit Binary Value - Meaning
0 000 - setuid, setgid, sticky bits are cleared
1 001 t+s sticky bit is set
2 010 g+s setgid bit is set
3 011 +tg+s sticky and setgid bits are set
4 100 u+s setuid bit is set
5 101 +tu+s setuid and sticky bits are set
6 110 +ug+s setuid and setgid bits are set
7 111 +tug+s setuid, setgid, sticky bits are set

Meaning of Sticky, SGID and SUID bits

Sticky

If set, then replaces "x" in the others permissions to "t", if others have execute permissions, or to "T" otherwise.
Examples:
-rwxrwxrwt both others execute and sticky bit are set
-rwxrwxr-T sticky bit is set, bit others execute is not set

-> Prevent deletion of an object even by a user than has writing permissions.

SGID

If set, then replaces "x" in the group permissions to "s", if group has execute permissions, or to "S" otherwise.
Examples:
-rwxrws--- both group execute SGID are set
-rwxr-S--- SGID is set, but group execute is not set

-> Object temporarily inherit from object group owner permissions for any group that usually has execution permissions on this object When set to a directory, any created object nested in that directory will inherit from this group instead of the one from the current creator (root for root or users, etc.).

SUID

If set, then replaces "x" in the owner permissions to "s", if owner has execute permissions, or to "S" otherwise.
Examples:
-rws------ both owner execute and SUID are set
-r-S------ SUID is set, but owner execute is not set

-> "Run as". Object temporarily inherit from object user owner permissions for any user that usually has execution permissions on this object. Prevent sushi attack with SUID restriction for shell scripts, and any user (not owner) editing a file will reset SUID flag to 0.

Clone this wiki locally