UNIX: Tutorial on chmod

In unix, you can get chmod information by typing: ls -la

This will give you a listing as such:
drwxr-xr-x 16 root root 1024 Oct 20 19:56 .
drwxr-xr-x 9 root root 1024 Sep 5 22:56 ..
drwxr-xr-x 9 foo user 1024 Sep 5 22:56 dir1
drwxr-xr-x 9 foo user 1024 Sep 5 22:56 dir2
drwxr-xr-x 9 foo user 1024 Sep 5 22:56 dir3
-rw-r--r-- 9 foo user 1024 Sep 5 22:56 file1

The drwxrxxx stuff to the left represents the item's permission, and are in groups of 3's, where:

r = read
w = write
x = execute

The group of 3 represents:

user
group
world

Since 2^3 = 8, permissions range from 000 to 777, where:

0 = No permissions
1 = Execute
2 = Write
3 = Execute & Write
4 = Read
5 = Execute & Read
6 = Read & Write
7 = Execute & Read & Write

chmod -R 755 dirname

will result in rwx r-x r-x (7-5-5) for the directory dirname

No comments: