How to set file and directory permissions recursively in Linux Print

  • linux, permissions, files, directories, plesk, ispconfig
  • 0

Incorrect permissions on directories or files will often result in unexpected behavior, and can make your system insecure.

Browsers will also often return a 500 error if the permissions on web server directories and files are not correctly set.

This article explains how to recursively set the correct privileges on directories and files respectively.

Note: This is also useful if you need to reset the permissions on your WordPress files and directories.

Table of contents

  • How to set file and directory permissions using FileZilla,
  • How to set file and directory permissions using Plesk,
  • How to set file and directory permissions using the Linux command line.

How to set file and directory permissions using FileZilla

If you are hosted on one of our ISPConfig 3 servers, or you have a managed server with us, or simply prefer working in FileZilla, then this is the method you may want to use.

Follow these steps to recursively set permissions on either files, directories or both.

  • Connect to your web root via FTP, using the FTP client called Filezilla. In ISPConfig 3, this will be the /web directory.
  • Navigate to the root directory of your application. In this example we are using WordPress, and are correcting the WordPress permissions.
  • Right click on the directory or file and select the 'File permissions' option. In this case we are changing only the directories and sub directories' permissions to 755, which are the standard permissions for WordPress installations.

FileZilla directory permissions

  • That's it. FileZilla will now recurse through your directories and sub directories, setting the permissions to 755.
  • If you want to set the files only, be sure to set the 'Apply to files only' option, and be sure to set the permission check boxes to 644.

FileZilla file permissions

How to set file and directory permissions using Plesk

Plesk has a full featured file manager, which includes the ability to set file and directory permissions from within your control panel web interface.

Follow these steps to set the right permissions for your system.

  • Log in to the Plesk control panel for the subscription assigned to your web application. In this case, we will use octoid.co.za (our WordPress manager website), and will be using a WordPress installation as our example.
  • Once logged in, navigate to the Websites & Domains section from the left side navigation bar.
  • Choose your subscription from the dashboard. This will bring up the management page for the selected domain:

websites & domains dashboard

  • Click on the 'File Manager' option under 'Dashboard' --> 'Files & Databases'. This will open the file manager which allows you to manage the root directory for this web space.

Plesk File Manager

  • Left click to the left of line of the directory for which you are wanting to set the correct permissions, and choose the 'Change Permissions' option.

  • Set the permissions to 755, graphically this would be;
    • Read is checked for Owner, Group and Others,
    • Write is checked for Owner only, and
    • Execute/search is checked for Owner, Group and Others.
  • Check the 'Change permissions recursively' option to ensure that all the directories and sub directories have the correct permissions. (WordPress sets all directories to 755).
  • Click on the blue 'Save' button at the bottom of the screen to initiate the change.

Note: Plesk DOES NOT allow for the setting of files separately from directories. If you recurse into sub directories with 755, then all files will have incorrect permissions. For this reason it is HIGHLY recommended that you use the FileZilla method, or the following command line method if you need to reset permissions on a website application such as WordPress.


Was this answer helpful?

« Back