Rabu, 05 November 2014

CHMOD Linux Command (octal mode)

What is CHMOD ?
chmod is a way to change permission of file or directory in linux. with this command we can get more access to file or directory.


Permission is mean : read, write and execute (r w x)

syntax :
chmod options permissions filename
 
 

The distribution of access rights.
 
There are 3 digits, each digit represents the permissions of the file.
as an example, consider the following three lines of the file and note the first line of the blue:


 drwxr-xr-x   2   root root     4096 Nov  5 20:48 cdebconf
-rw-------         1   root root 107916 Nov  5 20:48 partman
-rw-r--r--        1   root root   68631 Nov  5 20:48 status


The blue letters are made up of 10 letters, we count on the leftmost line, the first letter 'd' symbolizes the directory, the letter 2 to 4 symbolizes the user rights, letter 5 to 7 symbolizes the right group, and 8 to 10 letters symbolize the rights of other.

 drwxr-xr-x   2   root root     4096 Nov  5 20:48 cdebconf
 12345678910
 
then we broke into three groups (user, group, and other), each group has 3 letters,
note the following line:

 d    rwx     r-x    r-x        2   root root     4096 Nov  5 20:48 cdebconf
  1    2 3 4    5 6 7    8910
       user    group     other



the use of numbers in octal mode.
the highest number in the octal mode are 7 and the lowest number is 0.
figure 7 we divide into 4 groups of numbers, ie numbers 4,2,1 and 0, or in other words the number 7 is the sum of the numbers 4 + 2 + 1 + 0.



number 4 means 'read'
number 2 means 'write'
number 1 means 'execute'

number 0 mean 'none or no permission'
 
Example calculation:


chmod 754 filename

to simplify the calculations it will be my like into 3 groups: the first group with the number 7 is the right user, the second group with the number 5 is the right group, while the third group is the number 4 is the right of.


chmod 754 filename
chmod        7                             5                      4                           filename
                4+2+1                          4+0+1                      4+0+0
        read+write+execute      read+no write+execute    read+no write+no execute
                 user                                group                        other 


so with the explanation, the numbers 754 mean the folder has permissions for the user is a full access (read,write, execute) permissions, to the group have read and execute, while the other only has read access rights.

 conclusion :

drwxr-xr--  is equal to 754
 


2 komentar:

Related Posts Plugin for WordPress, Blogger...