chmod
Definition
chmod (change mode) is a command on Unix-like systems that changes file system permissions — read (r), write (w) and execute (x) — for the user (owner), group and others. Permissions can be specified symbolically (for example u+r, g-w, o=x) or numerically (octal values such as 755 or 644). chmod can also set special permission bits: setuid, setgid and the sticky bit.
Why it matters
Correct file permissions control who can read, modify or run files and enter directories. Proper use of chmod is essential for system security, running scripts, deploying applications and sharing files on multi-user systems. Incorrect permissions can break services or expose sensitive data.
Example in VCA
- Make a script executable so it can be run directly: chmod +x ./deploy.sh
- Make your projects directory accessible but not writable by others: chmod 755 ~/vibe-projects
- Restrict a private key to the owner only: chmod 600 ~/.ssh/id_rsa
These examples assume a Unix-like shell (macOS, Linux, WSL). Use -R to apply changes recursively when you mean to change permissions of a directory tree.
Another Real World Example
Web hosting commonly requires files to be readable by the web server but not world-writable. Typical settings are 644 for files and 755 for directories:
- chmod 644 /var/www/html/index.html
- chmod 755 /var/www/html
System directories sometimes use special bits: /tmp often uses the sticky bit so users cannot delete others’ files (chmod 1777 /tmp). Some privileged programs use setuid (for example chmod 4755 on an executable to allow it to run with the file owner’s privileges).
Common mistakes
- Using 777 (world read/write/execute) which is overly permissive and a security risk.
- Confusing numeric (octal) and symbolic modes or miscalculating octal values.
- Forgetting that the execute bit is required on directories to enter them and on scripts to run them directly.
- Running chmod without -R on directory trees when you intended a recursive change, or using -R carelessly and exposing many files.
- Expecting chmod to control Windows ACLs; Windows uses a different permissions system (use icacls or the Explorer GUI).
- Not considering umask, which affects default permissions when files are created.
- Mistaking file ownership issues for permission problems — chown may be needed instead.
Related terms
- File permissions
- umask
- chown
- setuid
- setgid
- sticky bit
- executable bit
- Access Control List
- recursive flag