- what SUID, SGID, and the sticky bit do,
- practical use cases (especially for shared directories),
- commands to configure and verify them,
- a real-world SUID example (the
passwdcommand).

Special permissions modify behavior rather than typical access. Use them intentionally—especially SUID—because they affect security boundaries.
At a glance: What each special bit does
Permission bit notation quick reference
- The
scharacter appears in place of anxwhen SUID or SGID is set and the execute bit is present (e.g.,rws). - An uppercase
SorTindicates the special bit is set but the corresponding execute bit is not set. - Use
chmodwith numeric or symbolic notation:- Numeric:
chmod 4755 filesets SUID (4= SUID). - Numeric:
chmod 2750 dirsets SGID (2= SGID). - Numeric:
chmod 1777 /tmpsets the sticky bit (1= sticky).
- Numeric:
Demo: Shared directory with SGID + sticky bit
Scenario assumptions:- Two users:
dev1anddev2. - Both users are members of group
devteam. - We create a shared directory
/shared, make root the owner, and configure group-controlled collaboration.
- Create the shared directory, set ownership and SGID with full owner/group permissions, no permissions for others:
- Verify directory permissions and SGID bit:
s in the group permission slot indicates SGID):
- Test SGID inheritance:
- Switch to
dev1, create a file in/shared, and inspect ownership.
devteam due to SGID on the directory):
- Enable the sticky bit so only file owners (or the directory owner/root) can delete files:
T because “others” have no execute bit; sticky bit is present):
- Test deletion restriction with the sticky bit:
- Switch to
dev2and try to removefile1(owned bydev1).
dev2 is in devteam and group permissions might otherwise allow deletion, the sticky bit prevents dev2 from removing a file owned by dev1. Only dev1, the directory owner (root), or root can remove it.
Do not broadly apply SUID to arbitrary executables—doing so can introduce serious security risks. Use SUID only for carefully audited programs that require it.
Real-world SUID example: /usr/bin/passwd
A classic SUID binary is/usr/bin/passwd. Regular users must be able to update their password, which requires writing to /etc/shadow—a file owned by root. Setting SUID on the passwd program allows the program to run with root privileges while the user still only executes the passwd binary.
Check the passwd binary:
s in place of x):
passwd is setuid to root, it can update /etc/shadow on behalf of a user without granting the user full root privileges.
Summary and best practices
- Use SGID on shared directories to ensure new files inherit the group’s ownership and simplify permission management.
- Use the sticky bit on shared directories (like
/tmpor team shares) to prevent users from deleting other users’ files. - Apply SUID sparingly and only to well-audited, trusted binaries that require elevated privileges for a limited, specific task.
- Always verify permission bits with
ls -land test behavior with representative users.