Help Center

Change file permissions via command line

Files and folders with incorrect permissions can be vulnerable to unauthorized access, which could compromise the integrity of your data and the security of your website. Additionally, incorrect permissions can lead to operational issues such as read or write errors.

You will learn how to change file permissions to 0644 and folder permissions to 0755 using the command line. Remember to exercise caution when making changes to permissions and ensure that you select the correct files and folders.

Before making any adjustments, VERIFY the permission of your "public_html" directory; it's usually set to 0750. Keep this in mind as we'll need it in the final step.

Follow the instructions carefully to keep your files secure and running smoothly!

  1. Open the terminal on your operating system.
  2. To change file permissions to 0644, execute the following command:
    # find /home/user/public_html -type f -exec chmod 0644 {} \;
    This will search for all files within the current directory and its subdirectories and assign them the 0644 permissions.
  3. To change folder permissions to 0755, execute the following command:
    # find /home/user/public_html -type d -exec chmod 0755 {} \;
    This will search for all folders within the current directory and its subdirectories and assign them the 0755 permissions.
  4. With steps 2 and 3, changes were made up to the "public_html" directory. Restore it with the following command and the value you obtained BEFORE starting:
    # chmod 0750 /home/user/public_html

 

Make sure to replace "/home/user/public_html" with the location of the folder containing the files you want to manipulate.

Remember that changing file and folder permissions incorrectly can affect the operation of your system, so be sure to select the appropriate files and folders before executing the commands.

It is advisable to create a backup of your files before modifying permissions so that you can restore them in case of any issues.

Last updated: 25 de abril de 2024

Estimated reading time: 3 minutes

Did this article help you?
Let's Do It!

Start TODAY for only $2.45/month

Includes a web builder, 30GB of cloud storage, +200 Apps, and professional email.

Sign Up Now