What is the chmod Command?
chmod (short for "change mode") is a command-line utility used in Unix and Linux operating systems to change the access permissions of files and directories. It controls who can read, write, or execute a specific file.
Understanding Octal Permissions
Octal permissions represent access rights using three numbers (e.g., 755). Each digit represents a specific user class: the first digit is for the Owner, the second is for the Group, and the third is for the Public (others). The number is calculated by adding the values of the allowed permissions: Read is 4, Write is 2, and Execute is 1.
Common Permission Presets
- 777: Full read, write, and execute permissions for everyone. Extremely dangerous for web servers.
- 755: Owner can read, write, and execute. Everyone else can only read and execute. Common for executable scripts and directories.
- 644: Owner can read and write. Everyone else can only read. Standard permission for static web files (HTML, CSS, images).
- 600: Only the owner can read and write. Used for highly sensitive files like private SSH keys or database configs.
