chmod
chmod is abbreviation of "change mode" , used to
change the permission of files and folders.
There are three USERs who are granted permission or revoked permission.
They are "USER or the OWNER" , "GROUP" , "OTHER".
There are three permissions , "READ", "WRITE" , "EXECUTE".
The READ, WRITE and EXECUTE are represented by the letters
" r ", " w ", "
x " .
r = READ a file or a directory
w = WRITE to a file or a directory
x = EXECUTE a file or a directory
Permission to each member (OWNER or GROUP or OTHER) can be rwx or rw or wx or rx or r or w or x .
In numerical representation : r = 4 , w = 2 , x =1 .
So,
rwx = 7 which is 4+2+1
rw = 6 which is 4+2
wx = 3 which is 2+1
rx = 5 which is 4+1
r = 4
w = 2
x = 1
Syntax:
chmod OWNERPermissionGROUPPermissionOTHERPermission fileName
which is:
chmod rwxrwxrwx fileName
Example:
chmod 777 file1 = OWNER,GROUP,OTHER can READ, WRITE and EXECUTE
the file1
chmod 400 file1 = OWNER can READ the file1 but OTHER members
have no access.
chmod 742 file1 = OWNER can READ/WRITE/EXECUTE , GROUP can READ
only, OTHER can WRITE only.
chmod 124 file1 = OWNER can EXECUTE only, GROUP can WRITE
only and OTHER can READ only.
chmod 567 file1 = OWNER can READ/EXECUTE, GROUP can READ/ WRITE
, OTHER can READ/WRITE/EXECUTE.
chmod 004 file1 = OWNER and GROUP have no access of
anything, OTHER can READ the file1
and so on.
There is another way of granting or revoking permissions:
+ add access/permission
- remove access/permission
= set access/permission
chmod a+rwx file1
=== add READ/WRITE/EXECUTE access to all(OWNER/GROUP/OTHER) on the file1.
chmod a-x file1 ===
remove EXECUTE access from all on the file1
chmod u=rwx, g=rw, o=r
file1 === set READ/WRITE/EXECUTE
access to USER, READ/WRITE access to GROUP , READ only access to OTHER.
chmod u-wx,g-w,o=
file1 === remove WRITE/EXECUTE
access from USER , remove WRITE access from GROUP, set no access to OTHER.
chmod u+w, g-w file1
=== add WRITE access to USER ,
remove WRITE access from GROUP.
chmod ug +rw file1
=== add READ/WRITE access to USER and GROUP.
chmod u=x, go =
rw file1, file2, file3 === set EXECUTE access to USER, READ/WRITE access to GROUP and OTHER to
file1 , file2 and file3.
and so on.
No comments:
Post a Comment