<mendelson:~/tmp> ls -l total 4 lrwxrwxrwx 1 selcuk 4 Oct 14 17:55 dnm -> hebe -rw-r--r-- 1 selcuk 24 Oct 14 17:43 hebe -rw-r--r-- 2 selcuk 69 Oct 14 17:43 ordek -rw-r--r-- 2 selcuk 69 Oct 14 17:43 ordek drwxr-xr-x 2 selcuk 512 Oct 14 17:44 subdir <mendelson:~/tmp>In the example above, there are three files, one directory and one symbolic link. The leftmost bit indicates what kind of a file it is. Possible kinds are listed below.
d Directory l Soft link (Not a real file. Used as a shortcut) c Character-type special file (Device files) b Block-type special file (Device files) p FIFO file (pipe) s Socket file (Used for communication between processes)
Example: You want to give read, write ,execute permissions to yourself, and read, execute permissions to group and others for the directory tmp. The corresponding permission bits are marked as one, and others are marked as zero. Starting from left, group three bits and change them to octal numbers by sequence. In our example, leftmost number is 7, middle number is 5 and rightmost number is 5.
owner group other r w x r w x r w x r:read permission 1 1 1 1 0 1 1 0 1 w:write permission \ / \ / \ / x:execute permission -|- -|- -|- 7 5 5Once you calculate the number you should give the command "chmod 755 tmp". If you ls the directory, the output will look as follows.
mendelson:~> ls -ld tmp drwxr-xr-x 2 selcuk 512 Oct 14 17:26 tmp mendelson:~>If you ignore the leftmost letter 'd', remaining nine characters are the corresponding permission bits. If there is a '-' for a bit, this means that the corresponding user does not have that permission. In out example, group and other does not have the second permission (write permission).
<mendelson:~> ls -l ceng111 -rwx--x--x 1 selcuk 716 Oct 6 11:01 ceng111* <mendelson:~> chmod g+rw ceng111 <mendelson:~> ls -l ceng111 -rwxrwx--x 1 selcuk 716 Oct 6 11:01 ceng111*As you can see from the example, the permissions of owner and others did not change. Also the existing permissions of group (x) was not deleted. The read and write permissions were added on.
<mendelson:~/tmp/subdir/second/dnm> cd /home1/selcuk/tmp <mendelson:~/tmp/subdir/second/dnm> cd ../../.. <mendelson:~/tmp/subdir/second/dnm> cd ~/tmpNote that there exists a '
~
' character instead of /home1/selcuk in the prompt.