This guide provides the commands for recursively changing file and directory permissions across a hosting account. Useful for fixing permission issues after migrations, restores, or mass file uploads.
# Directories: 755, Files: 644
find /home/username/public_html -type d -exec chmod 755 {} \;
find /home/username/public_html -type f -exec chmod 644 {} \;
01. Standard Web Hosting Permissions
- Directories: 755 (owner rwx, group rx, world rx)
- Files: 644 (owner rw, group r, world r)
- CGI/Perl scripts: 755 (must be executable)
- Config files with passwords: 600 or 640
- WordPress wp-config.php: 600 or 640
On CloudLinux/cPanel servers, 777 permissions are rejected by Apache/LSAPI as a security measure. Files set to 777 will return a 500 error. Use 755 for directories and 644 for files.
02. Recursive chmod Commands
Set All Directories to 755
find /home/username/public_html -type d -exec chmod 755 {} \;
Set All Files to 644
find /home/username/public_html -type f -exec chmod 644 {} \;
Both at Once
find /home/username/public_html -type d -exec chmod 755 {} \; -o -type f -exec chmod 644 {} \;
Faster Alternative with xargs
find /home/username/public_html -type d -print0 | xargs -0 chmod 755
find /home/username/public_html -type f -print0 | xargs -0 chmod 644
The xargs method is significantly faster on accounts with many files because it batches the chmod calls instead of forking a new process for each file.
03. Using find for Granular Control
Change Only PHP Files
find /home/username/public_html -name "*.php" -exec chmod 644 {} \;
Make CGI Scripts Executable
find /home/username/public_html/cgi-bin -name "*.cgi" -exec chmod 755 {} \;
find /home/username/public_html/cgi-bin -name "*.pl" -exec chmod 755 {} \;
Secure Config Files
find /home/username/public_html -name "wp-config.php" -exec chmod 640 {} \;
find /home/username/public_html -name "configuration.php" -exec chmod 640 {} \;
find /home/username/public_html -name ".htaccess" -exec chmod 644 {} \;
04. Fixing Ownership
After a restore or migration, files may be owned by the wrong user:
# Fix ownership for the entire account
chown -R username:username /home/username/public_html/
# Fix ownership for a specific addon domain
chown -R username:username /home/username/addondomain.com/
cPanel includes a built-in tool to reset permissions for an account:
/scripts/fixperms username
This resets home directory, public_html, mail, and other standard directories to cPanel's expected permissions.
Need Permission Help?
If you are seeing 403 or 500 errors related to permissions, our team can fix them for you.
Open a Support TicketQuick Recap
- Directories: 755 via
find -type d -exec chmod 755 - Files: 644 via
find -type f -exec chmod 644 - Never 777 on shared hosting
- Fix ownership:
chown -R username:username - Or use:
/scripts/fixperms username
5,186 users found this article useful · Last updated March 2026 · Browse all Server Maintenance articles
