Thursday, July 2, 2009

CHMOD

CHMOD is used to change permissions of a file. It’s a UNIX command that lets the system know how much access it should permit to a file.

PERMISSIONS                              COMMAND
U              G              W
rwx         rwx        rwx                   chmod 777 filename
rwx         rwx        r-x                    chmod 775 filename
rwx         r- x         r-x                   chmod 755 filename
rw-         rw-          r--                   chmod 664 filename
rw-          r--           r--                  chmod 644 filename



U = User
G = Group
W = World

r = Readable
w = writable
x = executable
- = no permission


An easier way to keep this in mind always.

Eg : rwx         rwx         rwx          chmod 777 filename
        111           111           111 , that makes a 777
         rw-          rw-         r--         chmod 664 filename
        110        110          100, that makes a 664

Binary      Becomes
--------------------
000             0
001             1
010             2
011             3
100             4
101             5
110             6
111             7