The Mathematics of Linux Permissions
Linux represents access permissions through a three-digit octal notation (or four digits when special flags are set). Each digit is the sum of three distinct binary bit values.
Bit Weights
Write (w) = 2 (Binary 010)
Execute (x) = 1 (Binary 001)
No Access (-) = 0 (Binary 000)
Because 4, 2, and 1 are powers of two, every sum from 0 to 7 maps to an unambiguous combination of permissions. For instance, 6 can only be 4 + 2 (read and write), while 5 can only be 4 + 1 (read and execute).
Standard Server Permission Configurations
644: Standard Web Files and Assets
The owner can read and write; group members and the public can read only. Ideal for HTML files, PHP source files, stylesheets, and images.
755: Directories and Executable Scripts
The execute bit on a directory allows users to enter and list contents. Setting 755 allows the web server daemon to traverse folders while reserving modification rights for the owner.
600 / 400: SSH Keys and Secret Credentials
Only the owner has read and write (600) or read-only (400) rights. The right setting for private encryption keys, database passwords, and .env configuration files.
1777: Shared Directories with Sticky Bit
The sticky bit (1) ensures that any user can write files into the folder, but only the file owner can delete or rename their own files. Used for /tmp and shared cache directories.
Octal vs Symbolic Chmod Syntax
Chmod supports two command styles:
Octal Mode (Absolute)
chmod 755 script.sh
Sets all nine permission bits simultaneously to match the exact octal code.
Symbolic Mode (Relative)
chmod +x script.sh
Adds or removes specific bits without altering untouched flags.