How to reset wordpress folder and file permissions to prevent malware

We all know that how critical it is to set proper file and folder permissions of WordPress setup on your website. There are lots of security plugins available which can reset and resolve file permission issue on your wordpress site. But here I will share you some quick and easiest way to reset wordpress folder and file permission.

File and Folder permission is quiet important thing for your wordpress website.

  1. Wrong permission PHP file can harm your website and any kind of malware can be inserted in such files.
  2. Wrong Directory permission can be used as backdoor on your web server.

Understanding Linux file permission:

Linux permission is represented in 3 digit and divided into 3 by 3 matrix as below.

Linux_File_Permission_Wordpress

 

  • First digit
    What actions (Read, Write, Execute) a User Owner of the file / folder can do
  • Second digit
    What actions (Read, Write, Execute) users of a Group of owner of the file / folder can do
  • Third digit
    What actions (Read, Write, Execute) world user (other users) can do

Before we go into the ways of resetting wordpress file and folder permission, Its required to know What is default Folders and Files permission on wordpress site.

  1. Default Folder permission on wordpress: 755
  2. Default File permission on wordpress: 644

I will share two ways by which you can reset permissions on your wordpress blog.

  1. Using Command line (SSH access on your server)
    – To reset wordpress files and folder permissions you need to log into your web-server using SSH client like putty.
    – Navigate to wordpress directory
    – execute below command to reset all folder

    sudo find . -type d -exec chmod 755 {} +

    – execute below command to reset all files

    sudo find . -type f -exec chmod 644 {} +

  2. Using PHP file (reset-permission.php)
    – Create a PHP file and write below code (Download)
    wordpress_reset_file_folder_permission
    – Save PHP file as resetpermission.php
    – place PHP file at root directory of your wordpress setup
    – navigate to www.yourdomain.com/resetpermission.php and wait for execution to finish.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!