Linux and macOS file permissions decide who can read, write and execute each file. They're shown two ways: as numbers like 755 in chmod commands, and as letters like rwxr-xr-x in ls -l output. This calculator converts between the two, explains what each group of users can do, and writes the chmod command for you.
How it works
Permissions come in three sets: the file's owner, its group, and everyone else. Each set has three bits: read (r = 4), write (w = 2) and execute (x = 1). Add the bits you want for each set to get one digit from 0 to 7.
So 7 = 4 + 2 + 1 = rwx, 5 = 4 + 1 = r-x, and 4 = r--. The three digits together, owner then group then others, make the mode: 754 means rwxr-xr--.
For a folder, execute means permission to enter it and reach files inside, and read means permission to list its contents. A folder usually needs x as well as r to be useful.
An optional fourth digit in front sets special bits: 4 is setuid, 2 is setgid and 1 is the sticky bit. They show up as s or t in place of x. /tmp typically uses the sticky bit so users can't delete each other's files.
A worked example
For a deploy script you want to run yourself, let your team read, and hide from everyone else, use 754. The owner gets 7 (read, write, execute), the group gets 5 (read, execute) and others get 4 (read only). Symbolically that's rwxr-xr--, and the command is chmod 754 deploy.sh.
Questions people ask
What does chmod 755 mean?
The owner can read, write and execute; the group and everyone else can read and execute. It's the usual setting for scripts, programs and web folders: rwxr-xr-x.
What does chmod 644 mean?
The owner can read and write; everyone else can only read: rw-r--r--. It's the common default for ordinary files such as web pages and config files that don't need to run.
Why is chmod 777 dangerous?
It lets every user on the system read, change and run the file. On a server, that can let a compromised process or another user alter your code. Grant only what's needed, such as 755 or 644.
What permissions should an SSH private key have?
600 (rw-------): readable and writable by the owner only. SSH clients refuse to use a private key that other users can read.
How do I change permissions for a folder and everything in it?
Add -R: chmod -R 755 folder. Be careful, because it gives files and folders the same mode. A common approach is 755 for folders and 644 for files, set separately with find.