Linux & POSIX Security

•

Quick Reference

Linux Chmod Permissions Cheat Sheet

Complete reference for UNIX/Linux octal permissions, symbolic strings, umask values, and security recipes.

Read (r)

4

Allows viewing file contents or listing directory contents.

Write (w)

2

Allows modifying file contents or creating/deleting files in directory.

Execute (x)

1

Allows running scripts/binaries or entering directories (cd).

Permissions Reference Matrix

OctalSymbolicClassificationRecommended Use CaseCommand
777-rwxrwxrwx
Danger

Full read, write, and execute for all users. Never use on production servers.

755-rwxr-xr-x
Standard

Standard for web server directories, CGI scripts, and executable binaries.

750-rwxr-x---
Secure

Executables shared between owner and group, hidden from others.

700-rwx------
Strict

Private scripts and personal directories (e.g. ~/.ssh directory).

666-rw-rw-rw-
Caution

Read and write for all users without execute rights. Rarely recommended.

644-rw-r--r--
Standard

Standard for web files, images, CSS, JavaScript, and documents on servers.

640-rw-r-----
Secure

Confidential configuration files accessible by owner and system group.

600-rw-------
Strict

Private keys, credentials, SSH keys (~/.ssh/id_rsa), and .env files.

444-r--r--r--
Standard

Read-only files for everyone, preventing accidental deletion or edits.

400-r--------
Strict

Strict read-only for owner (AWS EC2 .pem key pairs, root secrets).

000----------
Locked

Zero permissions for all users. Completely locked file.

Special Permissions: SUID, SGID & Sticky Bit

4000

SUID (Set User ID)

Executes file with owner privileges rather than runner privileges (e.g. /usr/bin/passwd).

chmod u+s /path/to/binary
2000

SGID (Set Group ID)

Inherits group ownership for newly created files inside the directory.

chmod g+s /path/to/directory
1000

Sticky Bit

Prevents non-owners from deleting other users files in a shared folder (e.g. /tmp).

chmod +t /tmp