Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Define SUID, SGID and sticky bits with basic difference.

There are three special permissions that are available for executable
files and directories:

  1. SUID (Set User ID):
    • What it does: When SUID is set on an executable file, it allows the file to be executed with the privileges of the file owner.
    • Example: If a regular user runs an executable file with SUID set and owned by the root user, the file will execute with root-level privileges.
  2. SGID (Set Group ID):
    • What it does: When SGID is set on an executable file, it allows the file to be executed with the privileges of the file’s group.
    • Example: If a regular user runs an executable file with SGID set and owned by a specific group, the file will execute with the privileges of that group.
  3. Sticky Bit:
    • What it does: When the sticky bit is set on a directory, only the root user, the owner of the directory, and the owner of a file within that directory can delete or modify their own files.
    • Example: In a directory with the sticky bit set, if User A creates a file, only User A, the root user, or the directory owner can delete or modify that file.

Differences:

AspectSUID (Set User ID)SGID (Set Group ID)Sticky Bit
PurposeExecute with owner’s privilegesExecute with group’s privilegesRestrict file deletion/modification
Applied toExecutable filesExecutable filesDirectories
Effect on Non-executable FilesNo effectNo effectNo effect
Effect on Executable FilesChanges effective user ID (EUID) to file owner’s IDChanges effective group ID (EGID) to file’s group IDNo effect after execution
DirectoriesNo effectNo effectRestricts file deletion/modification to root, directory owner, and file owner
Common Use CaseRunning programs with elevated privilegesRunning programs with group-level privilegesSecure deletion in shared directories

Leave a Comment