File permissions control who can read, write, and execute files. Here's how to understand and set them correctly.
February 25, 2026 · 6 min · 1087 words · Rob Washington
Table of Contents
Unix permissions determine who can do what with files and directories. Understanding them is fundamental to system security and avoiding “Permission denied” errors.
Who: u (user), g (group), o (others), a (all)
Operation: + (add), - (remove), = (set exactly)
Permissions: r, w, x
1
2
3
4
5
6
7
8
9
10
11
12
# Add execute for ownerchmod u+x script.sh
# Remove write for group and otherschmod go-w file.txt
# Set exact permissionschmod u=rwx,g=rx,o=r file.txt
# Add execute for everyonechmod a+x script.sh
chmod +x script.sh # Same thing
For directories, permissions mean something different:
r = Can list contents (ls)
w = Can create/delete files inside
x = Can enter directory (cd) and access files
1
2
3
4
# Typical directory permissionschmod 755 mydir # Others can enter and listchmod 700 mydir # Private directorychmod 750 mydir # Group can enter and list
# Change all files in directorychmod -R 644 /path/to/dir
# Change only directoriesfind /path -type d -exec chmod 755{}\;# Change only filesfind /path -type f -exec chmod 644{}\;# Combined approachchmod -R u=rwX,g=rX,o=rX /path
# Capital X = execute only if directory or already executable
# Check current permissionsls -la file.txt
# Check if you're the ownerstat file.txt
# Check directory permissions (need x to access files inside)ls -ld /path/to/directory
Permissions seem complex but follow a simple pattern: three classes (user, group, others), three permissions (read, write, execute), represented as either letters (rwx) or numbers (4+2+1=7). Start with the common patterns (755, 644, 600), and you’ll handle 90% of permission tasks.
📬 Get the Newsletter
Weekly insights on DevOps, automation, and CLI mastery. No spam, unsubscribe anytime.