Knowledge Base - FAQ
Question: Help! I don't understand UNIX file permissions!To list the permissions for a directory telnet into your site and use the command:
ls -l <directory>
You will see a list of the files in the directory. The first column of the list gives you information about the permissions on each file, such as:
-rwxrwxr-x
The ten-character string above can be interpreted as follows:
- 1st character: Indicates the nature of the thing being listed (- means an ordinary file, d means directory, l means symbolic link).
- Characters 2-4: Specify the owner's permissions. For example, rwx means that the owner of the file has read, write and execute access, while rw- would mean that the owner has read and write access but not execute access.
- Characters 5-7: Specify the group's permissions. In the above example, the group has read, write and execute access.
- Characters 8-10: Specify the permissions for people other than the owner and group (such as world wide web surfers). In the example above, such users have read and execute access to the file but not write access.
To change permissions on a file or directory use the chmod command. The chmod command is of the form:
chmod xyz <filename>
Where x indicates the type of permission to be given to the owner, y indicates the type of permission to be given to the group, and z indicates the type of permission to be given to other users. x, y and z are digits which are calculated as described below.
Each type of permission has a numeric code:
- Read permission = 4
- Write permission = 2
- Execute permission = 1
You add up the relevant codes to figure out what number to use in your chmod command. For example:
- Read plus execute access = 5
- Read plus write plus execute access = 7
- No access = 0
So to give the owner rwx access, the group r-x access and other people no access to the file test.cgi, you would use the command:
chmod 750 test.cgi
For more information please refer to the Linux manual page:
man chmod




