Labels

Monday, June 27, 2016

[Linux] chmod

Chomd in linux

If you are familiar with unix-like system, you are definitely using a lot the command chmod to change the access permission in a file or directories.
Like this one:
$ chmod -R 777 myDirectory
means recursively adds read, write and execution permission for owner, group and the others. -R means add these permissions on all files and all sub-directories in myDirecotories.
For the series of digits 777, the first 7 means adds read, write and execution permission for the file's owner; the second 7 means adds read, write and execution permission for users who are members of the file's group; the last 7 means adds read, write and execution permission for users who are neither the file's owner nor members of the file's group.
Besides digit 7, linux has other digits to indicate different permissions. In fact these digits are octal numbers
#Permissionrwx
7read, write and executerwx
6read and writerw-
5read and executer-x
4read onlyr--
3write and execute-wx
2write only-w-
1execute only--x
0none---
(Source: wiki https://en.wikipedia.org/wiki/Chmod)