Changing file and folder permissions

Changing file and folder permissions in ISPManager5

If you aim to change particular file or folder permissions, follow this path: ‘File Manager - WWW - the necessary folder or file’. 

Choose the necessary folder / file and issue the ‘Attributes’. 

In a new window, specify the desired rights: 

  1. Set the rights to read, write, and run the file for the owner. The right to run it for a directory means the possibility to view the file’s content.
  2. Set the rights to read, write, and run the file for the group. The right to run it for a directory means the possibility to view the file’s content.
  3. Set the rights to read, write, and run the file for those not owning files and not included in the group. The right to run it for a directory means the possibility to view the file’s content.

Additionally, in the ‘Change child elements’ field, a user can set a different owner and change file permissions and directories.

To end the operation, click ‘OK’.

How to Change File and Folder Permissions With FTP

To your attention there is a method to change the permissions with a FTP client FileZilla. 

Start by connecting with your account. Press the right mouse button to issue the root directory and see where it’s available to change access rights.

Connecting to the account with FTP.

Right-click on the necessary file or folder to select ‘File Permissions’. 

A new window will pop up where you will be able to change file permissions. If you work with a directory, try to change permissions recursively by choosing the option to ‘Redirect to subdirectories’. Save changes. 

Standard permissions, as a rule, are these:

  • ‘Files-644’
  • ‘Folders-755’
  • ‘Permissions-777’

The latter grants a user with privileges, no matter if this is a main user, group, or other users of this system. That’s why, ‘Permissions-777’ is not safe and not advised to install. 

How to Change Permissions on Files and Folders With SSH

Another tool to let you change permissions for several files and categories for specific owners (owner) and groups (group) is Chmod. 

Every file and folder (directory) has an owner or group owning them. This is done to differentiate the rights for: 

  • reading (r, read)
  • writing (w, write)
  • running / execution (x, execute)

This is different for owners and users (u) from the ownership group (g) and others (o). 

An example is 750 and rwxr-x- - - (the owner in this case has total access to the file, whereas the owner group can open and run it, but can’t edit or delete it, and others are completely denied access to this file). 

Syntax

Chmod [—Rvf]  [access rights]  [File / Files / File Catalog]

The part [Access rights] contains either numeric or symbolic value.   [File / Files / File Directory] indicates the path to file (absolute or relative)

Switches R, v, f

  • R: recursively change directory permissions, subdirectories, and nested files
  • v: detail description of completing the change of access permissions or impossibility of these actions
  • f: don’t initiate an error message for files and those directories for which permissions can’t be changed

Chmod access rights

Access rights depend on the user’s manner of interaction with files and directories, namely: 

  • r: read
  • w: write
  • x: execute

These rights are to be assigned to these user groups: 

  • File or directory owner
  • Users included in the owner’s group
  • Others

Rights definition chart: 

To write a right for the owner to grant reading and writing access and give others read-only rights, these rights must be given: rw-r- - r- - 

Now, look at the columns Octal and Character. Visually it is seen that the rw-r- - r- - symbolically looks like 644 in octal. 

Let us summarize it and try to change the permission ‘to grant everyone access to reading and the owner the right to change the content’ for the index.php file. 


chmod -v 644 index.php  

Checking Chmod Permissions


ls -ld index.php 


Here index.php is the checked file or directory


Illustration of the Correct Use of Chmod

As default, permission rights for directories is 755, for files 644. So, in many cases, you will only need these rights. 

Here is an example of how to set permissions 0644 on all files in the /var/www recursively and 0755 on subdirectories and directories. 


cd /var/www/example.com  

find ./ -type f -exec chmod 0644 {} \;  

find ./ -type d -exec chmod 0755 {} \;


The first command helps you go to the desired

directory. Then, use the find command to look for the right type: 

  • f for files 
  • d for directories

Then, run chmod with the expected rights. 

If you have a hard time with setup or would like to ask more questions, feel free to contact our support team at the ticket system.



Blog
Subscribe to our Newsletter