Monday, March 28, 2011

chmod linux command

chmod command is used to change the file access permission.


Simple example:



1) chmod 644 file1.txt
This gives the file read/write by the owner and only read by everyone else (-rw-r--r--).


2) chmod 755 file2.txt
This gives the file read/write/execute by the owner and read/execute by others (-rwxr-xr-x).




Syntax:
chmod [permission] file name


options:


-c, --changes    : report only when a change is made

-f,  --quiet       : suppress most error messages
      --help        : display this help and exit
-R,  --recursive : change files and directories recursively

-v,  --verbose   : output a diagnostic for every file processed




Permissions:
u - User who owns the file.
g - Group that owns the file.
o - Other.
a - All.


r - Read the file.
w - Write or edit the file.
x - Execute or run the file as a program.






Numeric Permissions:
400 read by owner
040 read by group
004 read by anybody (other)


200 write by owner
020 write by group
002 write by anybody


100 execute by owner
010 execute by group
001 execute by anybody

No comments:

Post a Comment