How to Change File or Directory Permission via Hosting Control Panel or SSH?

By default, our hosting system sets permission for files and directories to 0644 and 0755 respectively. It’s the most secure way to host your files. If you need, you can change them at your own risk.

Here is how you can change permissions through the hosting control panel:

DirectAdmin

  1. Go to your client area to the “Services – My services” section and click the “Login to Direct Admin” button;
  2. The Direct Admin panel will be opened. Go to the “System Info & Files” section and click the – File Manager” button;
  3. The File Manager will be opened. Find the needed file or folder using the file manager navigation;
  4. Move your cursor over the needed file or folder name and click the Set Permissions button in the appeared menu;
  5. A new window where you can set permissions to your file or folder will be opened:
    • you can set the permissions by hitting checkboxes under the columns with permission types or by typing the permission index manually (664 for files and 755 for folders by default);
    • in case you change the permissions to a folder, you can set the “Recursive” checkbox to change the permissions to all the files and subfolders inside this folder;
    • here you can see a full path to the current file or folder also;
  6. Make the necessary changes to the file and click the “Save” button. 

cPanel

  1. Go to your client area to the “Services – My services” section and click the “Login to cPanel”;
  2. The cPanel will be opened. Go to the Files section and click the File Manager button;
  3. The File Manager will be opened. Find and mark the needed file or folder using the file manager navigation;
  4. Click the Permissions button located in the upper right corner of the window;
  5. Check as many checkboxes as necessary to properly configure the rights. The code under the flags will update automatically;
  6. Make the necessary changes to the file or folder and click the Change Permissions button. 

ISPmanager

  1. Go to your client area to the “Services – My services” section and click the “Login to ISPmanager button;
  2. The ISPmanager will be opened. Go to the Dashboard – File manager” section;
  3. The File Manager will be opened. Find and mark the needed file or folder using the file manager navigation;
  4. Click the “Edit – Attributes button located in the top center of the window;
  5. In the window that opens, set the necessary permissions;
  6. In the drop-down list Change child elements you can change the permissions for files and(or) directories;
  7. Make the necessary changes and click the Ok button

Plesk

  1. Go to your client area to the “Services – My services” section and click the “Login to PleskExtended”;
  2. The Plesk panel will be opened. Go to the Websites & Domains section and click the button File Manager;
  3. To the right of the required file, click on the menu icon and select Change permissions;
  4. In the window that opens, set the necessary permissions;
  5. Check the box Replace permission entries on all child objects with the entries displayed here so that all subfolders and files will be assigned the appropriate permissions;
  6. Make the necessary changes and click the Save button.

General information about files and folders permissions

Permission rights are divided into file permissions and directory permissions. They have the same symbol designation, but their meanings are different.

File permissions

  • r – the access to read data from the file;
  • w – the access to change the contents of the file (writing);
  • x – the access to execute the file.

In UNIX, in theory, any file can be executed. Whether it is executable or not is determined by the file’s execution permission.

Permission to a folder (directory):

  • r – the right to read the folder (get a list of files that are contained in the folder);
  • w – the right to modify the folder contents (create and delete files);
  • x – the right to enter the folder.

If a user has full permission to the file, but no permission to the folder, where the file is located, he cannot perform operations with the files.

File permissions are divided into three categories:

  • u – file owner;
  • g – a member of the same group the file owner belongs to;
  • o – all others.

At the moment of connecting to the server, it determines which group the visitor belongs to and what accesses are available to him.

When a user connects to the server via FTP by entering his username and password, the server identifies him as a U – file owner. A regular visitor logged into the site, the server identifies him as O – everyone else.

Variations of the three possible permission values (r, w, x) for the three user categories (u, g, o) determine the file permissions.

How are the files and folders permissions generated?

Permissions are specified sequentially as follows: first the permissions for the file owner, then for the group, then for all others. If some permissions are not specified, i.e. some actions are prohibited, they are replaced with “-“.

Example:

The owner of the file has read, write, and execute rights, and all other users have read-only rights. The permissions will look like this: rwx r– r–

The numeric expression of the rights combinations:

  • r is replaced by 4
  • w is replaced by 2
  • x is replaced by 1

Based on this, the combination of rights rwx r– r– will be expressed numerically as 744

Recommended permissions combinations

Folders 755 – an owner can do everything, the group and everyone else can only read folders and enter them, but they are not allowed to write files, change file names, or delete files in directories. (rwxr-xr-x)

Files 644 – owner (user) can read and modify files, but he is not allowed to execute them, and all others are not allowed to modify and execute files, they can only read them. (rw-r–r–)

For folders and files that you may need to write to on behalf of users, it is recommended to set permissions to 777 and 666, respectively.

For site security purposes, we do not recommend leaving unreasonably high permissions. They can be overrated temporarily, if required, and lowered again after completion.

How to change permissions for folders and files on UNIX?

There are several options:

  • Changing permissions on folders and files on UNIX hosting is best via SSH. Even if you have never worked via SSH, there is nothing complicated about it. First, you need to download and configure an SSH client. For your convenience, you can first use the command ls -al to request a list of all files in the current directory. You will also be able to see the current permissions of the files in alphabetical expression. You can change the rights with the command chmod 0755 filename, where instead of 0755 you can specify the rights you want.
  • You can also change permissions using an FTP client. Each client has its own functionality for changing permissions on folders and files.
Rate this article
Share this article
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
In this article