chmod calculator
Tick the permissions you want, or type a mode like 755, rwxr-xr-x or u+x. You get the octal number, the letters ls shows and the chmod command to run.
| Who | Read | Write | Execute |
|---|---|---|---|
| Owner | |||
| Group | |||
| Others |
How chmod numbers work
Each digit is one group of people: the owner, the file's group, and others (everyone else). Add up read = 4, write = 2 and execute = 1 to get the digit. So 7 is rwx, 6 is rw-, 5 is r-x and 4 is r--. 755 means the owner can do everything, and everyone else can read and run it.
| Mode | Letters | Typical use |
|---|---|---|
| 644 | rw-r--r-- | Normal files: web pages, configs, documents |
| 755 | rwxr-xr-x | Scripts, programs and folders |
| 600 | rw------- | Private files such as SSH keys (~/.ssh/id_ed25519) |
| 700 | rwx------ | Private folders such as ~/.ssh |
| 664 / 775 | rw-rw-r-- / rwxrwxr-x | Files and folders a team shares through a group |
| 400 | r-------- | Read-only secrets, like AWS .pem keys |
| 1777 | rwxrwxrwt | Shared scratch folders like /tmp |
| 777 | rwxrwxrwx | Anyone can change it. Almost never the right fix. |
Symbolic mode: u+x, go-w
chmod also takes changes: who (u owner, g group, o others, a all), an operator (+ add, - remove, = set exactly) and permissions (r, w, x, s, t). chmod u+x deploy.sh makes a script runnable; chmod go-w file stops others editing it. Type a change in the box and it is applied to the current mode. Without a who (+x), chmod leaves out the bits in your umask, so chmod +w usually only adds write for the owner. X adds execute only to directories and to files someone can already execute.
Setuid, setgid and the sticky bit
A fourth leading digit sets the special bits: 4 = setuid (the program runs as its owner, like passwd), 2 = setgid (runs as the group; on a folder, new files inherit the folder's group) and 1 = sticky (in a folder, only a file's owner can delete it). ls shows them as s or t in place of x, or capital S / T when x is off.
Questions
What does chmod 755 mean?
Owner: read, write and execute (7). Group and others: read and execute (5). It's the usual mode for scripts, programs and folders.
What does chmod 644 mean?
Owner: read and write (6). Group and others: read only (4). It's the usual mode for ordinary files.
Why is chmod 777 bad?
It lets every user and process on the machine change or replace the file. Fix ownership with chown, or use 775 with a shared group, instead.
What permissions should my SSH key have?
600 for the private key (or 400), 644 for the .pub file, and 700 for the ~/.ssh folder. SSH refuses a private key that anyone but you can read or write.
Why does a folder need execute permission?
On a folder, x means you can enter it and reach the files inside. Without it, read only lists the names.
What is umask?
The bits taken away from new files (which start at 666) and folders (777). The common umask 022 gives 644 files and 755 folders; 077 makes everything private.