Issues with SFTP access after using sudo find command


I ran the following commands yesterday to update the permissions on files and directories for my WordPress site and now I cannot connect to the parent directory ( - example directory name) using SSH or SFTP.

sudo find /var/www/ -type f -exec chmod 640 {} \;
sudo find /var/www/ -type d -exec chmod 750 {} \;

These commands were recommended on this tutorial article:

My FTP client (Transmit, macOS) displays this error when trying to connect: Could not change directory to “/var/www/”.

Could someone share what is going wrong and possibly let me know how best to set permissions so that SSH and SFTP work correctly.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello Alex,

Thanks for the reply.

When I connect to the server via SSH using sudo and use the following command cd /var/www/, Terminal displays the following message: -bash: cd: /var/www/ Permission denied.

I tried checking the permissions using ls -l /var/www/ and the following message was displayed: ls: cannot open directory ‘/var/www/’: Permission denied.

If I run the sudo chown -R www-data:www-data /var/www/ command, I can access the directory, but the website itself goes down.

Any ideas on why I am having issues?


Hello, @mikehermary

Could you please clarify if the only directory you can’t access is the wp-content/themes? Can you access the WordPress core installation directory - public_html

I will recommend you manually check the current permissions and ownership of the directory and verify they’re indeed 750 for directories and 640 for the files.

Running these command should not cause any harm as they’re the recommended permissions for a WordPress site.

Regards, Alex