Linux Permissions Explained: rwx, SUID, SGID, Sticky

This title was summarized by AI from the post below.

Linux permissions + special bits 🐧 Deep-diving into Linux internals today starting with something we all see but rarely really understand: When you run: ---------------------- "ls -la" --------- u will see something like this -------------------------------------------- "-rwxr-xr-- 1 deploy deploy 9096 May 15 app.sh" ------------------------------------------------------------------------- Most people just chmod 777 and move on. I wanted to know exactly what every character means. Breaking down -rwxr-xr-- First character { - } = file type symbol Meaning -  regular file d  directory l  symbolic link Next 9 characters = permissions, 3 groups of 3: positions rwx → owner (user) positions r-x → group positions r-- → others ------------------------------------ Inside each group: r = read w = write x = execute - = no permission --------------------------- So here: owner: rwx → read, write, execute group: r-x → read, execute others: r-- → read only ---------------------------------- Octal notation (why 754 makes sense) r = 4, w = 2, x = 1 rwx = 7 r-x = 5 r-- = 4 So: chmod 754 app.sh → rwxr-xr-- ---------------------------------------------- Some useful patterns: 755 → executables / web app files 644 → config / text files 600 → private files (e.g. SSH keys) 777 → everyone can do anything (avoid in production) ----------------------------------------------------------------------------------- ======================== Special bits: SUID, SGID, Sticky On top of rwx, there are three powerful (and risky) bits: SUID (4xxx, e.g. 4755) File runs with the owner’s permissions (often root), not the caller’s. Great for specific system tools (like passwd), but dangerous on custom binaries. -------------- SGID (2xxx, e.g. 2755) File runs with the group’s permissions. Also used on shared directories so new files inherit the group. ------------- Sticky bit (1xxx, e.g. 1777) On a shared-writable directory, only the file’s owner can delete their own files. This is how /tmp works; without sticky, any user could delete anyone else’s files. ------------- From a security perspective, SUID and SGID are common privilege escalation paths if misused or left on custom binaries. These bits should always be audited and justified. I’m currently deep-diving into DevOps + DevSecOps, starting from fundamentals like this and moving toward modern hardening. Follow / connect if you want to see how to replace risky SUID/SGID usage with safer Linux capabilities in the next post. #Linux #DevOps #DevSecOps #CloudSecurity #LearningInPublic

  • text, letter

To view or add a comment, sign in

Explore content categories