For security reasons, users should make most of their files private unless they want to make them public. Users are not able to write to files in the root directory because they do not have privileges. There are three forms of permission: read, write and execute. These three forms can be used in any combination.
Permission to write means you are able to edit the contents of a file, which will overwrite anything that was written before. Permission to read means permission to copy. Execute means that a file may be used as a running process. Users have execute permissions to editors, compilers, etc. but they are not able to read or write to these files.
There are three types of access permissions: 1) owner, 2) group, 3) public.
For example this is what you would see in a directory listing:
total 24
drwxrwxr-x 6 smith users 766 Feb 28 19:32 . (1) drwxrwxr-x 8 smith users 290 Mar 15 9:25 .. (2) -rw-r--r-- 2 smith users 320 Jul 8 15:39 book (3) -rw------- 5 smith users 425 Apr 23 10:07 hw (4) drwxr-xr-x 1 smith users 512 Jun 29 17:21 public_html (5)
(1,2) gives the owner read, write and execute permissions, group has read, write, and execute permissions, and public has read and execute permissions on the directories.
(3) gives the owner read, write permissions, group read only, public read only
(4) gives the owner read and write privileges, group and public do not have access to the hw file.
(5) gives the owner read, write, and execute privileges, group and public have read and execute privileges only.
Each permission has a value:
read (r) = 4
write (w) = 2
execute (x) = 1
So (1,2) have permission 775 (4+2+1, 4+2+1, 4+0+1)
(3) has permission 644
(4) has permission 600
(5) has permission 755
In (5), the 7 is the permission for owner, the 5 is for group, and the 5 is for public.
To change the permission of a file all you need to do is type the combination of numbers to the permission you want to set for owner, group and public.
To do this type:
% chmod 644 filename
By doing this you have set the permission of the file to read and write access for owner and read for group and public. If there are --- this means that access is denied.