How do file permissions work?

This FAQ will help you understand what file permissions are and how they work.

In a Web server environment permissions are used to control which Web site owners can access which directories and files.


User Types:

File permissions can be confusing. The basic permissions come in three categories of user type:

Owner Permissions: Control your own access to files

Group Permissions: Control access for anyone in your group

Other Permissions: Control access for all others


Permission Types:

When permissions are configured, the server allows you to define different permissions for each of these three categories of users.

The permissions are:

r = Read permissions - read a file or list a directory's contents

w = Write permissions - write to a file or directory

x = Execute permissions - execute a file or recurse a directory tree


How it all works:

So as shown below each user type has the possibility to read, write & execute.

Owner Group Other
r w x r w x r w x

So now for the fun part! Each permission type is allocated a number as shown below.

Owner Group Other
r w x r w x r w x
4 2 1 4 2 1 4 2 1

To give the 'owner' user type read, write & execute permissions you would add the 4+2+1 which equals 7.

This can then be repeated for the other two user types giving a permission code of 777

4+2+1 4+2+1 4+2+1
= 7 7 7

This means that each user type would now have full permission on all files and directories.


Examples:

Commonly used for files on a web server.

644 = rw- r-- r--
Owner has Read, Write and Execute
Group has Read only
Other has Read only

Commonly used for directories on a web server.

755 = rww r-x r-x
Owner has Read, Write and Execute
Group has Read and Execute only
Other has Read and Execute only
Offer

Answer options

Your feedback was successfully added.

Answer tracking

Track

Watch the content of this article for changes.