Changing permissions on files and directories


Here's the result of the ls -l command on my home directory.

drwxr-xr-x   4 gali     grad1        4096 Feb  3 22:32 public_html
drwx------   2 gali     grad1        4096 Feb 28 02:00 subtest
drwx------   2 gali     grad1        4096 Nov 26 13:17 tex
lrwxrwxrwx   1 gali     grad1          36 Jan 27 14:48 lin -> ../some_file 

The first character is the type of the file: d for directory, l for link, - for a regular file.
The next 9 characters are for permissions:

The permissions on directory public_html are read, write and execute for the owner, read and execute for the group, and read and execute for the rest of the world. The permissions on the directory tex are are read, write and execute for the owner, and nothing for the group or the rest of the world.

Read is 4, write is 2, execute is 1. You get full permissions: read, write and execute by using 7 (7 = 4+2+1 ). You get read and execute permisisons by using 5 (5=4+1). The option for chmod (change mod or change permissions) is compused of three numbers: the first number for the owner, the second number for the group and the third number for the rest of the world.

To change permissions for a file use chmod

% chmod 755 file_name

where file_name or directory_name is the file or directory you want to change permissions to. Again, for file_name or directory_name you can use an absolute path or a relative paths, it's up to you. Make sure you list (ls -l) the contents of the directory that contains the file or directory who's permissions you changed so you can see the difference.