๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

๐Ÿ’ก Permissions & Ownership September 17, 2026 3

Linux Command: chmod

Change file and directory permissions

Terminal โ€” Permissions & Ownership
Command
$ chmod +x deploy.sh

chmod (change mode) modifies file and directory permissions. It controls who can read, write, and execute files using either symbolic notation (u+x, g-w) or numeric/octal notation (755, 644). Linux permissions are organized in three levels: owner (u), group (g), and others (o). Each level has three permission bits: read (r=4), write (w=2), and execute (x=1). chmod changes these permission bits. chmod is essential for security โ€” setting correct permissions prevents unauthorized access while allowing legitimate users to work. Common patterns: 644 for files (owner read-write, others read), 755 for directories and scripts (owner full, others read-execute).

Syntax

chmod [OPTION]... MODE FILE...

Key Options

  • +x โ€” Add execute permission
  • -R โ€” Recursive (apply to all files in directory)
  • u+x โ€” Add execute for owner only
  • g+w โ€” Add write for group
  • o-rwx โ€” Remove all permissions for others
  • a+r โ€” Add read for all (owner, group, others)

Examples

Make script executable

chmod +x deploy.sh

Standard file permissions

chmod 644 config.php

Standard directory permissions

chmod 755 /var/www/html/

Pro Tips

  • 644 = files (rw-r--r--). 755 = directories/scripts (rwxr-xr-x). 600 = private files (rw-------). 700 = private directories.
  • chmod 777 gives everyone full access including write. This is a security risk. Use specific permissions instead.
  • Special bits: setuid (4xxx) runs as file owner. setgid (2xxx) inherits group. Sticky bit (1xxx) prevents deletion by non-owners (/tmp).

Learn more: Full chmod reference โ†’

Share this tip