Command Line: chmod

Command Line: chmod

For Linux


 

Symbols

Get file permissions: ls-l

  • R – read
  • W – write
  • X – execute

User Levels

  • Owner
  • Group
  • World

Permissions

  • Assign file permissions: chmod permissions filename
  • Assign user/group permissions: chmod user group world filename

Permission numbers

  • 4 read (r)
  • 2 write (w)
  • 1 execute (x)
Practical Examples
  • chmod 400 mydoc.txt read by owner
  • chmod 040 mydoc.txt read by group
  • chmod 004 mydoc.txt read by anybody (other)
  • chmod 200 mydoc.txt write by owner
  • chmod 020 mydoc.txt write by group
  • chmod 002 mydoc.txt write by anybody
  • chmod 100 mydoc.txt execute by owner
  • chmod 010 mydoc.txt execute by group
  • chmod 001 mydoc.txt execute by anybody
Combinations
  • 7 = 4+2+1 (read/write/execute)
  • 6 = 4+2 (read/write)
  • 5 = 4+1 (read/execute)
  • 4 = 4 (read)
  • 3 = 2+1 (write/execute)
  • 2 = 2 (write)
  • 1 = 1 (execute)
Common Examples
  • chmod 666 mydoc.txt read/write by anybody
  • chmod 755 mydoc.txt rwx for owner, rx for group and rx for the world
  • chmod 777 mydoc.txt read, write, execute for all

Summarized from Linux.org

 

4955883782_c6ca21e9e8_b_chmod

Photo by mchelen