There are two types of chmod:
-
system letter coding (symbolic)
-
system numeric coding (octal number)
Every files and directories in linux have 3 access user.
The user (u), group (g) and owner (o).
When you type $ls -l at the console, you will some informations.
drw-r–r– 3 taufanlubis taufanlubis 4096 2007-07-31 16:07 download
d = directory (mean that ‘download’ is directory not file).
3 first characters are for user (u) -> rw- = read (r), write(w) and not executable (x)
3 second characters are for group (g) -> r-x = can be read (r), can not be written (-) and not executable (x)
3 third characters are owner (o) -> r-x = can be read (r), can not be written (-) and not executable (x)
-rwx-w-r– 1 taufanlubis taufanlubis 1020 2007-08-01 10:00 filecoba
1 first character -> – = file (not directory)
3 first characters are for user (u) -> rwx = read (r), write able(w) and executable (x)
3 second characters are for group (g) -> -w- = can’t be read (-), write able (w) and not executable (-)
3 third characters are owner (o) -> r– = can be read (r), can not be written (-) and not executable (-)
lrwxrwxrwx 1 root root 19 2007-07-31 11:15 S20powernowd -> ../init.d/powernowd
1 first character -> l = link
3 first characters are for user (u) -> rwx = read (r), write able(w) and executable (x)
3 second characters are for group (g) -> rwx = read (r), write able(w) and executable (x)
3 third characters are owner (o) -> rwx = read (r), write able(w) and executable (x)
How to change the permission with letter coding?
$sudo chmod ug+rx coba -> set user and group to be ‘read able’ (r) and executable (x)
$sudo chmod ug-rx coba -> set user and group to be ‘not read able’ (-) and not executable (-)
How to change the permission with system numeric coding?
4 = read
2 = write
1 = executable
$sudo chmod 721 coba
-> 7 (user) / 0 (group) / 0 (owner)
-> 7 = 4+2+1 (read+write+executable) for user
-> 2 = 0+2+0 (not read+write+not executable) for group
-> 1 = 0+0+1 (not read+not write+executable) for owner
$sudo chmod 644 coba
-> 6 (user) / 4 (group) / 4 (owner)
-> 6 = 4+2+0 (read+write+not executable) for user
-> 4 = 4+0+0 (read+not write+not executable) for group
-> 4 = 4+0+0 (read+not write+not executable) for owner




