totn UNIX

UNIX Basic commands: chmod

The chmod command changes the access mode of one file or multiple files.

Syntax

The syntax for the chmod command is:

chmod [option] mode files

Options

Option Description
-R Descend directory arguments recursively while setting modes.
-f Suppress error messages if command fails.

Mode

Mode Description
Who u=user, g=group, o=other, a=all (default)
Opcode + means add permission
- means remove permission
= means assign permission and remove the permission of unspecified fields
Permission r=Read, w=write, x=Execute, s=set uid bit, t=sticky bit
u=user, g=group, o=other, l=mandatory locking

Example

chmod 751 tech
chmod u=rwx, g=rx, o=x tech
chmod =r tech

* Please note that there are many flavors of UNIX, so if in doubt, consult your man pages.