What is Files and Directory Permission & How to Understand it in Ubuntu 12.04/14.04 and Red hat Linux 6 ...?
ll Command is used to display the information about the files and directory including date, time, users,group, size, name and permission.
Four symbols are used when displaying permission.
R : Read 4
W : Write 2
X : Execute 1
- : no permission
-rwxrwxrwx : files
drwxrwxrwx : directory
files and directory permission are symbolized by ten character.
If we want to change permission, then there are two methods:
1. symbolic
2. Numeric
1. Symbolic Method:
Syntax:
Chmod mode directory/filename
Mode Option:
1. u,g,o
2. w,r,x
3. +,-
4. =
1. # chmod u+rwx file or directory : in case of user only
2. # chmod ug+rwx file or directoty : in case of user and group
3. # chmod u+w,g+r,o+x directory/file
4. # chmod u+rw,g+rw directory/file
5. # chmod u-r, g-w,o-rw directory/file
6. # chmod ugo+rwx file/directory
7. # chmod ugo-rwx file/directory
+ is used to add permission
- is used remove permission
chmod ugo=rw directory/file
this command will assign read/write permission to u,g,o
suppose we have one file as
test.txt
permission : -r- - r- -r- -
chmod u=w,g=wx,o=w test.txt
this command will assign write to user, write/execute to group and write to other while remove the previous permission.
The main difference between +,= are + operator simply add the new permission with previous one and = assign the new permission while removing old (new permission overwrite an old)
2. Numeric Method:
In this method, calculation are based on following numbers
r=4 w=2 x=1 0= no permission
Example:
#chmod 777 file/directory
in this case user get 7 means that user has permission of read/write/execute, group get 7 means read/write/execute and ame for other
# chmod 531 file/directory
in this case user get 5 means that user has permission of read/execute, group get 3 means write/execute and other get 1 means that other has permission to execute.
#chmod 742 file/directory
7 : User : rwx
4 :Group : r
2 : Other : w
Thanking You
Hope U like it...