How to fix File Permission in Directadmin hosting at once

How to fix File Permission in Directadmin hosting at once

Hi there, For whatever reasons if you have a messed up file permissions in your directadmin hosting and you want to fix it all at once you have come to a right place to know how to do that. Recently one of my wordpress site which was hosted on a vps server which has  cloudpanel.io hosting control panel installed and I wanted to switch and transfer my websites to directadmin panel. So I faced a file permission problem while transfering it.

In Cloudpanel hosting control panel when we create a website somehow it doesnt have correct file permission set to its website files, it always set 0770 file permission to all its folders and website files. And thats why I downloaded its backup by compressing the folder and when I uploaded it to directadmin panel file manager and extracted it there, the file permission which was present in cloudpanel was also applied in direct admin.

For your Website security its always advised to have 0775 file permissions for folders and 0644 for any other files with extension in it. And when I faced this problem I tried to set permission 0775 to all files and floder in file manager for that domain. But the problem I faced was it was also setting 0775 permissons to files also which suppossed to be 0644. So I needed to set 0644 file permission to all website files with extension and 0755 to all its folders, and doing it one by one going inside each and every folder was taking to much time.

If I had ssh access I would have done it by running a single command. But I was on shared hosting, So I am going to tell you what I did to solve this trouble.

In order to set correct File permission first You have to Login to your directadmin dashboard and click on terminal inside System Info and Files section.

Then when terminal is connected with you username inside you will have to change directory to your desired domain root folder by running command

cd /home/user/domains/domain.com/public_html

When you run this change directory please change user with your username, when you run this command it doesnt looks like you have changed director at all like it does in any linux terminal. So I verified if i am inside right folder by running “ls” command, and it showed me the contents of the folder I am in.

Then in next step you need to run thees two commands one by one to set file permission to all files and folders, The first command is for setting 0775 permission to all folders and second command is to set 0644 permission to all files inside that folder.

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

So thats the way to set correct file permission to your websites files and folders without going to each file and folder and doing it manually. You can verify your files permissions by accessing file manager in your direct admin panel. Leave a comment if you need any help regarding this. Thats all for now, Thanks for reading this article.

Read more