Linux Commands Reference - Complete Linux Command Guide

Comprehensive Linux command reference with 150+ commands. Search, filter by category, and view detailed usage examples.

Share
Back to commands

chmod

Change file permissions

Syntax

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

Common Options

-RRecursive change
-vVerbose output
-cReport only if changes made
-fSuppress error messages
--referenceUse reference file permissions
-uSet user permissions
-gSet group permissions
-oSet others permissions
-XSet execute only for directories
-sSet SUID/SGID bits
-tSet sticky bit
--preserve-rootPrevent recursive change on root

Common Examples

chmod 755 file.sh

Set rwxr-xr-x permissions

chmod 644 file.txt

Set rw-r--r-- permissions

chmod 777 directory/

Set rwxrwxrwx permissions

chmod 700 private.key

Set rwx------ permissions

chmod +x script.sh

Add execute permission

chmod -R 644 directory/

Set permissions recursively

chmod u=rwx,g=rx,o=r file

Symbolic mode

chmod 4755 program

Set SUID bit

Numeric Permission Mode

Permission Calculation

Each permission is represented by a number: read(r)=4, write(w)=2, execute(x)=1. Add them up for each position.

Three-Digit Format

First digit=owner, second=group, third=others. e.g., 755 = owner 7(rwx), group 5(r-x), others 5(r-x)

Common Numeric Modes

NumericPermissionDescription
777rwxrwxrwxFull access for everyone (use with caution)
755rwxr-xr-xOwner full access, others read/execute (default for executables)
744rwxr--r--Owner full access, others read-only
700rwx------Owner only (private keys, configs)
644rw-r--r--Owner read/write, others read-only (default for files)
640rw-r-----Owner read/write, group read, others none
600rw-------Owner only (sensitive files)
555r-xr-xr-xEveryone read/execute (immutable executables)
511r-x--x--xEveryone execute, only owner can read
444r--r--r--Everyone read-only
400r--------Owner read-only
000---------No permissions

Special Permission Bits

Optional fourth digit: 4=SUID, 2=SGID, 1=Sticky bit

Related Commands

Related Tools

More Code & Dev Tools