Security & Permissions

chmod

Change file mode bits and access permissions (read, write, execute) for owner, group, and others.

COMMAND SYNTAX
$ chmod [options] mode file...

Common Options & Flags

Option / FlagDescription
-R, --recursiveChange files and directories recursively
-v, --verboseOutput a diagnostic message for every file processed
-c, --changesLike verbose but report only when a change is made
--reference=RFILEUse RFILE permissions instead of mode values

Practical Command Examples

$ chmod 644 file.txt

Sets Owner: read/write (6), Group: read-only (4), Others: read-only (4).

$ chmod 755 script.sh

Sets Owner: read/write/execute (7), Group & Others: read/execute (5).

$ chmod u+x deploy.sh

Adds execute permission specifically for the file owner.

$ chmod -R 750 /var/www/app

Recursively sets permissions on directory tree.

Production Real-World Use Case

Hardening web server document roots (e.g. Nginx/Apache) so script files are non-writable by public web users while remaining readable by www-data.

Common Mistakes

  • ✕Running chmod -R 777 on web roots (exposes write access to malicious users).
  • ✕Forgetting execute bit on shell scripts or directories (prevents cd navigation).

Security Considerations

Never assign 777 permissions in production. Always principle of least privilege (644 for files, 755/750 for directories).

Watch Command Video Breakdown

Linux chmod Command Video Tutorial
YouTubeLinux chmod Command Video Tutorial
Watch on TechSimpleHub YouTubeClick to play

Interactive Calculator Available

Use our visual tool for instant calculation.

Open Tool →