Tuesday, April 16, 2013

Unix File Permissions

The Unix files access is controlled. There are three types of access (permissions):
  • read
  • write
  • execute
Each file belongs to a specific user and group (ownership).

Access to the files is controlled by user, group, and what is called other/everyone permission bits and is usually set using a numerical value. For example, 644 as permission bit will result in:

Owner / User      Group    Other/ Everyone
         6                   4                 4

Each number represents the access level and it can be from 0 to 7. The access level, depending on the number is as follows:

0 - no access to the file whatsoever
1 - execute permissions only
2 - write permissions only 
3 - write and execute permissions
4 - read permissions only
5 - read and execute permissions
6 - read and write permissions
7 - read, write and execute permissions (full permissions)

Thus the above 644 permissions example will look like this:

Owner / User - Read and Write 
Group - Read and Write 
Other/ Everyone - Read only

To allow a script to be executed and read by everyone but the only one who can write in it is your user, you would need to set 755 as permissions.

No comments:

Post a Comment