Knowledgebase

Setting file and directory permissions


Problem:

File and Directory Permissions



Solution:

There are three levels of file permission: read, write and execute. In addition, there are three
groups to which you can assign permission, The file owner, the user group, and everyone. The command chmod followed by three numbers is used to change permissons. The first number is
the permission for the owner, the second for the group and the third for everyone. Here are how
the levels of permission translate:

0 = --- (no permission)
1 = --x (execute only)
2 = -w- (write only)
3 = -wx (write and execute)
4 = r-- (read only)
5 = r-x (read and execute)
6 = rw- (read and write)
7 = rwx (read, write and execute)

Here are the most common file permissions used:
chmod 604 [filename] (minimum permission for www HTML file)
chmod 705 [directoryname] (minimum permission for www directories)
chmod 705 [filename] (minimum permission for www scripts & programs)
chmod 606 [filename] (permission for datafiles used by www scripts)
chmod 703 [directoryname] (write-only permission for public FTP uploading)
chmod 755 [filename] (permission for CGI scripts)