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!
- Open the terminal on your operating system.
- 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. - 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. - 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.
Related articles
- Screen command in CentOs: more efficient sessions
- Solution: 'Service Unavailable' on CloudLinux servers
- Database export via command line
- Protect your data: configure RAID notifications with S.M.A.R.T.
- List CronJobs for all cPanel users
- Delete unnecessary files from the /tmp partition
- Change reserved disk space in CentOS
- Know your hardware: get accurate information on CentOS 7
- Basic SSH commands
- Optimize accounts with manual rearrange
- IP blocking in CSF via command line
- Clear DNS cache: solution to resolution problems
- How to open and close ports using CSF in WHM?
- How to Modify the Hosts File in Windows, Linux, and macOS
- How to Use Telnet to Test SMTP Connectivity on Port 25
- Adjusting reserved space on Linux disks
- Adjusting reconstruction speed in RAID on Linux
- Where are NGINX logs stored?
- Configuring RAID failure notifications with mdadm
- Differences between Legacy VPS and Cloud VPS
- Install cPanel in your server or VPS
- How to send emails via SSH?
- Manage screen session