Files and Folders Permissions
Table of Contents
All files and folders on UNIX machines (like the one that hosts your website) have access permissions. Access permissions define who and how can access your files and folders. There are different types of predefined access that you can choose from, as well as several different user groups you can grant access to.
Permission types
You can choose one of three predefined permissions types for all of your files and folders:
- Read – denoted as r. Files can be viewed by all users with access r.
- Write – denoted as w. Files can be modified by all users with access w.
- Execute – denoted as x. Files can be executed as programs by all users with access x.
User groups
All of the permissions above can be granted to a predefined number of user groups:
- User – this is the owner of the file.
- Group – this is the group of the user, who is owner of the file.
- World – everyone else.
Every file or folder of your website has different permissions for each of these groups. They are represented by numbers – the first digit defining the user access, the second the group’s and the third everyone else’s.
Here’s what each digit means:
- 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)
So if you’re looking to set permissions saying that a file can be only modified by its owner but it’s OK for everyone else to read and execute it, you should set its permissions to 755.
Which permissions should I use?
The web server needs to be able to read your web pages in order to be able to display them in a browser. The following permissions need to be set in order for your web site to function properly.
- All HTML files and images need to be readable by others. The permission for this is 644 (readable by User, Group and World, and writable by User). It is set automatically when you upload files.
- All folders need to be executable by others. The permission for this is 755 (readable by User, Group and World, writable by User, executable by User, Group and World). It is set automatically when you create a folder.
How do I change permissions for my files and folders?
WordPress sites
If you have a WordPress site, you can easily reset the permissions of your files and folders to the correct ones by using the Reset Permissions functionality. You can find it in Site Tools > WordPress > WordPress Install & Manage. Select the installation you wish to reset the permissions for, click on the Actions menu and select Reset Permissions.
Change permissions in File Manager
You can also change the permissions of your site in the File Manager. Go to Site Tools > Site > File Manager, select the file/folder and click Change Permissions (the key icon). A pop-up window will appear where you can customize the permissions for your website, file, or folder. If you are changing the permissions of a folder and you want to apply them to the subfolders and files, select Recursive. Once ready, click Confirm.
Other ways to change permissions
You can also change files and folders permissions via FTP or SSH. You can learn how to do this in our dedicated articles: