Skip to content

Instantly share code, notes, and snippets.

@nicolaschan
Last active June 2, 2022 10:42
Show Gist options
  • Save nicolaschan/8496337c603575a16ab1ffe2e3da127f to your computer and use it in GitHub Desktop.
Save nicolaschan/8496337c603575a16ab1ffe2e3da127f to your computer and use it in GitHub Desktop.

setuid/setgid/sticky Cheatsheet (Linux)

setuid (s) setgid (s) sticky (t)
Directory ignored New subfiles inherit group Only owner of subfile can (re)move it*
File Executes as file owner Executes as group ignored

Sticky bit can be set with chmod as the first of four digits, or using {+,-}s (for setuid/setgid) and {+,-}t (for sticky). For example, to enable setuid,

chmod u+s $FILE  # Add setuid to a file
chmod 4755 $FILE # Possible permissions of /bin/ping

Permissions displayed as an {s,S,t,T} in the third character of each permission section. For example,

-rwsr-xr-x 1 root root 68520 Aug 29 01:25 /bin/ping*
  • Since the setuid/setgid/sticky bit character is written in the same place as the execute bit, lowercase indicates execute bit is set and uppercase means execute bit is not set.

* Root and owner of the directory can also (re)move subfiles. Commonly used in /tmp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment