UNIX file and directory permissions (summary)
To make file readable by others (i.e., the “world”), set the directory containing the files to:
drwxr-xr-x
or
755
and set the files in the directory to:
-rwxr--r--
or
644
Explanation of file permissions
There are 3 classes of permissions:
- User (sometimes referred to as “owner”)
- Group
- Others (sometimes referred to as “all” or “world”)
A common notation for permissions is a series of 10 characters, such as:
drwxr-xr-x-rw-r--r---rw-rw-rw-
The first character represents the file type:
-regular fileddirectory
The remaining 9 characters represent 3 permissions for each of the 3 classes:
rread onwwrite onxexecute on-off
Directories must have execute permissions, such as:
drwx------drwxr-xr-x(most common)drwxrwxr-xdrwxrwxrwx
Executable program files, such as CGI scripts, must have execute permissions, such as:
-rwxr-xr-x
Regular files must have read and/or write permissions, such as:
-rw-r--r--(most common)-rw-rw-rw-
Read, write, and execute permissions may also be represented in octal notation:
4read on2write on1execute on-off
The octal values are added to result in desired read-write-execute permissions:
4+2+1=7for read-write-execute permissionsrwx4+2=6for read-write permissionsrw-4+1=5for read-execute permissionsr-x4=4for read permissionsr--
Examples of common octal notations are:
755is same asdrwxr-xr-x644is same as-rw-r--r--
See File System Permissions in Wikipedia for more information.
