| Preventing other users from reading your files |
read 4 write 2 execute 1For example suppose we execute the following Unix command:
ls -l somefileThe results of the command look like this:
-rwxr--r-- 4 someowner somegroup 512 Aug 9 15:34 somefileThis is a file on which the owner someowner has read write and execute permission and members of the group somegroup and other users have read permissions, so anyone one can read it but only the owner can write to it or execute it. To set this file so that only the owner can read it, and members of the group somegroup and other users have no permissions we use the following Unix command:
chmod 700 somefileThe first digit (for the owner is: 4 (read) + 2 (write) + 1 (execute) = 7; The next digit (for the group is: 0 (read) + 0 (execute) = 0; The final digit (for all other users) is also 0
-rwx------ 4 someowner somegroup 512 Aug 9 15:34 somefileThe second syntax is: chmod mode file1 file2 ...
In this systax mode can be any of the following settings:
u user (owner) g group o other + add permission - remove permission r read w write x execute
Example: chmod go-rwx public.html
removes read, write, and execute permissions for group and
other for the file public.html.
See the man pages for more information about the chmod command.