Search Our Database

How to troubleshoot WordPress Permission Error via Command Line (CLI)

Last updated on |

Introduction

WordPress permission errors typically occur due to incorrect file or directory permissions, often resulting in issues such as parent is not writable or errors during plugin installation. Using the Command Line Interface (CLI) allows administrators to quickly reset and correct permission settings, ensuring the site functions smoothly. This guide is for WordPress administrators looking to resolve permission errors by using the Command Line Interface (CLI) to adjust file and directory permissions, ensuring the site operates as expected.

 

Prerequisite

  • SSH access to the server
  • Basic knowledge of Linux/Unix commands
  • Understanding of WordPress directory structure
  • Basic understanding of file permissions
  • Optional: SSH access with root privileges

 

Step-by-step guide

Step 1: Access Your Server via SSH

  • Access your server via SSH. If you are non-having control panel like DirectAdmin or cPanel, you may continue Step 2 once connected.
    Else, if you are having control panel, you will need to switch to your control panel user before continuing on Step 2.

    sudo su <user>

Step 2: Locate your website root directory

  • Locate and navigate to your website root directory.
    For the server which not having control panel, the path typically will be as below:

    cd /var/www/html

    For the server which having control panel like DirectAdmin or cPanel, the path typically will be as below:

    cd /home/<username>/<domain>/public_html/

Step 3: Verify directory permissions

  • Verify the permission for wp-content by running command below.
    ls -la
  • The permission should be drwxr-xr-x.
  • Navigate to wp-content and verify the directories permissions within, such as plugins, uploads or themes.
    cd wp-content/

Step 4: Adjust directory permissions

  • If you noticed that the permission for the directories was not drwxr-xr-x, you may follow the command below to change the permission.
    chmod 755 wp-<name>

Step 5: Verify the directory ownership

  • If you are still receiving the error, may related to the ownership of the directories.
  • To change ownership of the directories, you will need to gain root privileges. If you have control panel, you will need to enter exit before running command below to gain root privileges.
    sudo su -
  • Navigate to your website root directory and verify the ownership of the directories by running command below.
    ls -la

    For control panel like DirectAdmin or Cpanel, ensure the owner was your username of the control panel.
    For non-control panel, ensure the owner was apache or nginx, depend on your configuration.
    For example, we take johnny as the owner for this.

Step 6: Adjust directory ownership

  • If you noticed that the permission for the directories was not correct user, you may follow the command below to change the ownership.
    chown <user>:<user> wp-<name>

 

Conclusion

By going through this guidance, you will be able to troubleshoot and fix WordPress permission errors using the Command Line, restoring proper access and functionality to your site.

 

For additional assistance or if you encounter any issues, please contact our support team at support@ipserverone.com.