Tutorial: chmod

The chmod command (abbreviated from change mode) is a shell command and C language function in Unix and Unix-like environments. When executed, it can change file system modes of files and directories. The modes include permissions and special modes.

The chmod command options are specified like this:

$ chmod [options] mode[,mode] file1 [file2 ...]         

To view the current file mode:

$ ls -l file  

Using chmod with octal numbers

Here is a summary of the meanings for individual octal digit values:

0 --- no permission  
1 --x execute   
2 -w- write   
3 -wx write and execute  
4 r-- read  
5 r-x read and execute  
6 rw- read and write  
7 rwx read, write and execute  

These are the examples from the Symbolic notation section given in octal notation:

  • "-rwxr-xr-x" would be represented as 755 in three-digit octal.
  • "-rw-rw-r--" would be represented as 664 in three-digit octal.
  • "-r-x------" would be represented as 500 in three-digit octal.

Here is a summary showing which octal digits affect permissions for user, group, and other:

  • UGO = User, Group, Other
  • 777 = "-rwxrwxrwx" = rwx for all
  • 754 = "-rwxr-xr--" = rwx for owner, r-x for group, r-- for other
  • 124 = "--x-w-r--" = x for owner, w for group, r for other


In this example the owner or user is given the permission to read, write, and execute, while group and other is only given the permission to read and execute::

$ chmod 755 myfile  
$ ls -l myfile  -rwx-r-x-r-x  1   57 Jul  3 10:13  myfile  





Jerry Peng, Undergraduate
Computer Engineering

e-mail: bpeng@umail.ucsb.edu