Site: US UK AU |

What are file and directory permissions?

What are file and directory permissions?

This article describes the different options available for setting the permissions of files and directories in different hosting environments.

Permission basics

Setting permissions is one of the most basic elements of web security. Assigning the correct permissions to the files and directories helps prevent data theft and malicious intrusions. Permissions specify who and what can read, write, modify, and access content on your site.

There are two different methods to express permissions in Linux. Permissions may be expressed numerically or alphabetically. At Nexcess, we prefer to numeric permissions because they are easier to read.

Each file and directory will have three permission categories for all users: owner, group, and other. The owner group identifies the owner of the file or directory. The group identifies entities assigned to the file or directory. The category of other lists all entities who do not fall into the other two categories.

There are three permission types: read, write, and execute.

  • Read: The capability to read contents. This is expressed as either the number 4 or letter r.

  • Write: The capability to write or modify. This is expressed as either the number 2 or letter w.

  • Execute: The capability to execute. This is expressed as either the number 1 or letter x.

It is critical to know the permissions of your files and directories. To list the contents of a directory and see the permissions, run this command.

ls -l

The output of this command would show a similar output to the following:

-rw-r--r--  1 user user   418 Oct 20 23:59 index.php

The columns in a directory listing like the one above are: permissions, number of links, owner, group, size, timestamp, and file or directory name.


Number of Links




Timestamp (last modified time)

File or Directory Name






Oct 20 23:59


Table 1. Directory columns.

In this example, the directory permissions, -rw-r--r--,  can be divided into the three permission categories.







r + w



4 + 2 + 0

4 + 0 + 0

4 + 0 + 0

Table 2. Permissions.

The permissions -rw-r--r-- translate into the numeric value 644. The read and write permissions’ numeric value is added to provide both read and write permissions to the owner category. Only the read permission is added to the group and other categories.

This is a breakdown of the combinations possible and the permissions they apply.

7 = 4 + 2 + 1 (read/write/execute)
6 = 4 + 2 (read/write)
5 = 4 + 1 (read/execute)
4 = 4 (read)
3 = 2 + 1 (write/execute)
2 = 2 (write)
1 = 1 (execute)

Restricting permissions

When setting permissions on your site, only provide the files and directories with as much access as they need. Open permissions like 777 give files and directories the unlimited capacity to modify and execute code, leaving your site vulnerable to attack. Files holding sensitive information should not be openly accessible, otherwise you risk compromising your site’s data and your visitor’s data.  


For 24-hour assistance any day of the year, contact our Support Team by email or through the Client Portal.

Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to change your Client Portal password
Added on Mon, May 21, 2018
How to manage firewall whitelists in SiteWorx
Added on Wed, Nov 12, 2014
How to use FIleZIlla
Added on Mon, Jun 11, 2018
How to transfer files using WinSCP
Added on Fri, Aug 15, 2014
What is chmod?
Added on Mon, Feb 23, 2015
What are the advantages of using SSH keys to control access for multiple users?
Added on Tue, Apr 5, 2016
How to activate two-factor authentication in SiteWorx
Added on Tue, Nov 28, 2017
How to create SSH keys in Windows with PuTTY
Added on Tue, Jul 25, 2017
How to add FTP accounts with SiteWorx
Added on Mon, Jun 11, 2018
How to set up FileZilla
Added on Mon, Jun 11, 2018