Setting File Permissions
File permissions control who can read, write, and execute files on your hosting account. Correctly setting permissions is essential for security and ensuring your website functions properly.
Understanding Permission Numbers
Permissions are represented by three digits, each ranging from 0 to 7. The three digits represent:
- First digit – Owner permissions (your account).
- Second digit – Group permissions.
- Third digit – Public permissions (everyone else).
Each digit is a sum of: 4 (read) + 2 (write) + 1 (execute). For example, 755 means the owner can read, write, and execute, while group and public can only read and execute.
Recommended Permissions
- Directories – Set to
755. This allows the owner full access and others can read and traverse the directory. - PHP and HTML files – Set to
644. Owner can read and write, others can only read. - Configuration files (e.g., wp-config.php) – Set to
600or640for extra security. Only the owner can read and write. - Executable scripts – Set to
755if they need to be executed by the server.
Changing Permissions in cPanel File Manager
- Open the File Manager in cPanel.
- Right-click on a file or folder and select Change Permissions.
- Tick or untick the checkboxes for Read, Write, and Execute for Owner, Group, and World.
- Click Change Permissions to apply.
Changing Permissions via FTP
In FileZilla, right-click a file or folder and select File Permissions. Enter the numeric value or use the checkboxes. You can apply permissions recursively to all subdirectories and files by ticking the Recurse into subdirectories option.
Security Warning
Never set permissions to 777 as this allows anyone to read, write, and execute the file. This is a serious security risk and can allow attackers to modify your website files. If a plugin or script asks for 777 permissions, look for an alternative solution.