Chmod Calculator
Tick read, write and execute for owner, group and others and get the octal mode, the rwx string and a ready-to-copy chmod command.
| Who | Read (4) | Write (2) | Execute (1) | Octal | Bits |
|---|---|---|---|---|---|
| Owner (u) | 7 | 111 | |||
| Group (g) | 5 | 101 | |||
| Public / others (o) | 5 | 101 |
7550755rwxr-xr-xu=rwx,g=rx,o=rx111 101 1010022chmod 755 deploy.shCommon modes
Umask preview
A umask lists the bits to take away from new files (which start at 666) and new directories (which start at 777).
new files 644 (rw-r--r--) ยท new directories 755 (rwxr-xr-x)
How chmod numbers work
A Unix mode is twelve bits. The lower nine are three groups of three - read, write and execute for the owner, the group and everyone else - and octal writes each group as one digit, which is the whole reason chmod uses octal. Read is worth 4, write 2 and execute 1, so 7 is rwx, 6 is rw-, 5 is r-x and 4 is r--. The three bits above them are setuid (4), setgid (2) and sticky (1), written as an optional leading digit: 4755, 2775, 1777.
Because each permission is a single bit, setting and clearing them is ordinary masking: mode | 0o020 adds group write and mode & ~0o002 removes world write. The bitmask generator and octal to binary converter show the same bits for any value.
Permission digit reference
| Digit | Binary | Symbolic | Meaning |
|---|---|---|---|
| 0 | 000 | --- | no access |
| 1 | 001 | --x | execute only |
| 2 | 010 | -w- | write only |
| 3 | 011 | -wx | write and execute |
| 4 | 100 | r-- | read only |
| 5 | 101 | r-x | read and execute |
| 6 | 110 | rw- | read and write |
| 7 | 111 | rwx | read, write and execute |
Common modes and where they belong
| Mode | Symbolic | Typical use |
|---|---|---|
| 644 | rw-r--r-- | Regular file: owner writes, everyone reads |
| 755 | rwxr-xr-x | Directory or script: owner writes, everyone runs/enters |
| 600 | rw------- | Private file, SSH private key, .env |
| 700 | rwx------ | Private directory, ~/.ssh |
| 640 | rw-r----- | Config readable by a service group |
| 775 | rwxrwxr-x | Shared team directory |
| 2775 | rwxrwsr-x | Shared directory, files inherit the group (setgid) |
| 1777 | rwxrwxrwt | /tmp: world-writable with sticky bit |
| 4755 | rwsr-xr-x | setuid binary such as passwd |
| 444 | r--r--r-- | Read-only for everyone |
Code Examples
chmod 755 deploy.sh # rwxr-xr-x
chmod 600 ~/.ssh/id_ed25519 # rw-------
chmod u=rwx,g=rx,o= app/ # symbolic: 750
chmod -R g+w shared/ # add group write, recursively
chmod 2775 shared/ # setgid: new files inherit the group
stat -c '%a %A %n' deploy.sh # 755 -rwxr-xr-x deploy.sh (GNU)Frequently Asked Questions
What does chmod 755 mean?
Each octal digit is three permission bits: read 4, write 2, execute 1. 7 = 4+2+1 = rwx for the owner, and 5 = 4+1 = r-x for the group and for others. So 755 is rwxr-xr-x: the owner can change the file, everyone can read it and run it (or enter it, for a directory).
What is the difference between 644 and 755?
Only the execute bits. 644 (rw-r--r--) suits ordinary files: the owner writes, everyone reads. 755 (rwxr-xr-x) adds execute for everyone, which scripts and programs need to run and directories need so people can cd into them and reach the files inside.
What permissions should an SSH private key have?
600 (rw-------) or 400 (r--------). OpenSSH refuses to use a private key that the group or others can read, with the error "UNPROTECTED PRIVATE KEY FILE". The ~/.ssh directory itself should be 700.
What is the fourth digit in chmod 4755 or 1777?
The special bits: setuid 4, setgid 2 and sticky 1. 4755 is a setuid program that runs with its owner's privileges (passwd works this way). 2775 makes new files in a shared directory inherit its group. 1777 is /tmp: anyone can create files, but only a file's owner can delete it.
What do a capital S or T mean in ls -l output?
That a special bit is set without the execute bit under it. rwSr--r-- is setuid with no owner execute, which does nothing useful on a regular file and is usually a mistake. A lowercase s or t means both the special bit and execute are set.
How does umask relate to chmod?
umask lists the bits to remove from new files. New files start from 666 and new directories from 777, then the umask bits are cleared: the common umask 022 gives 644 files and 755 directories, and 077 gives 600 and 700. umask never adds execute to a file.
Is chmod 777 safe?
Rarely. 777 lets every user on the machine modify or replace the file, and on a web server it lets any compromised process rewrite your code. Fix the ownership with chown instead, and use 755 or 775 for directories and 644 or 664 for files.
Related Tools
This tool runs entirely in your browser - nothing you enter is uploaded or stored.