Using chmod to modify file permissions in Linux Centos via CLI

Managed Hosting / DIY Hosting : VPS / Dedicated Server / Cloud Hosting

Many times, we see the following message being displayed after uploading all the files to the server.



Here are a few swift ways to resolve it.
Assuming that your dedicated server / VPS server / cloud server are linux based.

First, log into your dedicated server / VPS server / cloud server using putty.
Then, su to root.

After that, navigate to the directory of the files that were uploaded.
Example : cd /home/user/domains/domain.com/public_html

There are three commands to run each after another.

The first one I would normally run is:
sudo chown -R username:userrname /home/username/public_html/

If you are using cpanel or CWP [Centos Web Panel] for your VPS server / dedicated server / cloud server, chances are the username and the folder name are the same.
Say if your username for the account is t5210yarco1webqo
Example:
sudo chown -R t5210yarco1webqo:t5210yarco1webqo /home/t5210yarco1webqo/public_html/

Then the second command would be:
find . -type d -exec chmod 0755 {} \;

And the third command is:
find . -type f -exec chmod 0644 {} \;

Here is an example:


Your website shall now be able to be displayed normally.
- End -


Comments