File and Directory:
‘ll’ 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
W : Write
X : Execute
- : 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:
- symbolic
- Numeric
- Symbolic Method:
Syntax:
Chmod mode directory/filename
Mode Option:
- u,g,o
- w,r,x
- +,-
- =
- # chmod u+rwx file or directory : in case of user only
- # chmod ug+rwx file or directoty : in case of user and group
- # chmod u+w,g+r,o+x directory/file
- # chmod u+rw,g+rw directory/file
- # chmod u-r, g-w,o-rw directory/file
- # chmod ugo+rwx file/directory
- # 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)
- 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
No comments:
Post a Comment