Command Syntax

The chmod (change mode) command alters file system permissions. Basic terminal syntax is:

chmod [OPTIONS] MODE FILE...

Common Command Line Options

OptionFlag NameDescription & Purpose
-RRecursiveApply permission changes recursively to all subdirectories and files inside target directory.
-vVerboseOutput a diagnostic message for every processed file.
-cChangesLike verbose, but reports only when a change is actually made.
--reference=RFILEReferenceCopy permissions from reference file RFILE instead of specifying octal/symbolic mode manually.

Practical Command Examples

1. Setting Octal Mode

# Set directory to 755 and file to 644chmod 755 /var/www/htmlchmod 644 /var/www/html/index.html

2. Adding or Removing Specific Permissions (Symbolic)

# Make a shell script executable for the ownerchmod u+x deploy.sh# Remove write access from group and otherschmod go-w document.txt# Grant read access to all userschmod a+r public-readme.txt

3. Recursive Bulk Permission Updates

# Recursively fix all directories to 755 without touching filesfind /var/www/site -type d -exec chmod 755 +# Recursively fix all regular files to 644 without touching directoriesfind /var/www/site -type f -exec chmod 644 +

Generate CHMOD Commands Interactively

Use the command builder in our tool with live recursive flag output.

Launch Command Builder →