How to read a mode
A mode is three groups of three bits: owner (u), group (g) and others (o). In each group r = 4, w = 2, x = 1 and the digit is their sum: rwx = 7, r-x = 5, r-- = 4. So rwxr-xr-x is 755. The first character in ls -l output is the type: “-” file, “d” directory, “l” symlink.
Numeric or symbolic command
chmod 640 file sets the whole mode. The symbolic form can change single bits — chmod g+w file or chmod o-rwx file — leaving the rest alone. The calculator prints the symbolic command with “=” (u=rw,g=r,o=), so the result does not depend on the current mode either.
FAQ
What is the difference between 755 and 644?
755 (rwxr-xr-x): the owner can do everything, others read and execute — used for directories and scripts. 644 (rw-r--r--): the owner writes, others only read — regular files, configs, static assets. Without x you cannot cd into a directory or read the files in it.
Why is chmod 777 a bad idea?
Any local user and any process (including a compromised PHP script) can modify the file or drop in their own. Permission problems are usually solved with the right owner: chown www-data:www-data with 755/644, or a shared group with 775/664.
What does the fourth digit in 2775 or 1777 do?
Those are special bits: 4 is setuid, 2 is setgid, 1 is sticky. 2775 on a directory makes new files inherit its group; 1777 (like /tmp) lets everyone write but only delete their own files.
Why doesn't chmod 755 clear setgid on a directory?
With a three-digit numeric mode GNU chmod keeps setuid and setgid on directories. Clear them with five digits (chmod 00755 dir) or explicitly: chmod g-s dir.
What permissions does an SSH key need?
Private key 600 (or 400), ~/.ssh directory 700, authorized_keys 600. With wider permissions OpenSSH refuses the key with “UNPROTECTED PRIVATE KEY FILE”.
