chmod is a linux command which is the abbreviation of change mode. It is used manually change the permission of a file.

A file permmission determines wheter a class (owner/group/others) can perform an action (read/write/execute)

Different classes

  • owner determines the user
  • group determines the group
  • others any user who is not owner and doesn’t belongs to group

Different Permissions

Execute ability to run the file as an executable program Write ability to modify the contents of the file Read ability to open and view the content

each class has a file permission which can be displayed using numeric notation

file permissions are defined as follows

  • 0 – no permission allowed
  • 1 – can execute
  • 2 – can write
  • 4 – can read

we can generate octal numbers for each group as a combination of these file permissions

Notation Permission
0 No Permission
1 Execute
2 Write
3 (1+2) Execute and Write
4 Read
5 (1+4) Execute and Read
6 (2+4) Read and Write
7 (1+2+4) Read Write and Execute

Examples:

  • chmod 600 – owner can read and write
  • chmod 700 – owner can read, write and execute
  • chmod 666 – all can read and write

 

What Does Chmod 777 Mean?

Setting file permission to 777 means any one can do read,write and execute the file. This can be a security risk since anyone who has access to the system can do anything with the file