Changing file and folder permissions

Changing File and Folder Permissions in ISPmanager 5

To change the permissions of a file or folder, go to File Manager > WWW and open the folder you need.

Select the file or folder and click Attributes. In the new window, set the permissions:

  • for the owner: read, write and execute;
  • for the group: read, write and execute;
  • for others (users who are not the owner and not in the group): read, write and execute.

For a file, execute means running it as a program. For a directory, read allows listing its contents, and execute allows entering it.

In the Change child elements field, you can also set a different owner and change the permissions of all nested files and directories. Click OK to finish.

How to Change File and Folder Permissions with FTP

Here is how to change permissions with the FileZilla FTP client.

  1. Connect to your server in FileZilla with your FTP or SFTP account.
  2. Right-click the file or folder and select File permissions.
  3. In the new window, set the permissions. For a directory, select Recurse into subdirectories to apply them to all nested files and folders.
  4. Click OK to save the changes.

The standard permissions are:

  • 644 for files;
  • 755 for folders.

Permissions 777 give full access to everyone: the owner, the group and all other users of the system. They are not safe, and we do not recommend using them.

How to Change Permissions with SSH

Over SSH, permissions are changed with the chmod command. It works for one or many files and directories.

Every file and directory has an owner and a group. Permissions are set separately for:

  • the owner (u);
  • the group (g);
  • others (o).

Each of them can have three rights:

  • read (r);
  • write (w);
  • execute (x).

For example, 750 or rwxr-x--- means that the owner has full access, the group can read and execute but cannot change the file, and others have no access.

Syntax

chmod [-Rvf] [permissions] [file(s) or directory]

Permissions can be set as numbers or symbols. The path to the file can be absolute or relative.

Options

  • -R: change permissions recursively for a directory, its subdirectories and nested files;
  • -v: show a detailed report for every file;
  • -f: do not show error messages for files whose permissions cannot be changed.

Permission values

OctalCharactersMeaning
0---no access
1--xexecute
2-w-write
3-wxwrite and execute
4r--read
5r-xread and execute
6rw-read and write
7rwxread, write and execute

For example, to give the owner read and write access and everyone else read-only access, use rw-r--r--. In octal notation, this is 644: 6 for the owner, 4 for the group and 4 for others.

Let us give everyone read access and the owner the right to change the index.php file:

chmod -v 644 index.php

Checking permissions

ls -ld index.php

Here index.php is the file or directory you want to check.

Setting permissions for a whole site

By default, directories usually have 755 permissions and files have 644, and in most cases these are all you need. Here is how to set 644 on all files and 755 on all directories of a site recursively:

cd /var/www/example.com
find ./ -type f -exec chmod 0644 {} \;
find ./ -type d -exec chmod 0755 {} \;

The first command opens the site directory. Then find searches for objects of the given type (f for files, d for directories) and runs chmod with the required permissions for each of them.

If you need a server with ISPmanager, take a look at our ISPmanager VPS plans. If you have any questions, contact our support team through the ticket system.

Blog
Subscribe to our Newsletter