GrepBoardTools GrepBoard manuals ↗ Log ↗

Tools / Server config

chmod · umask calculator

Type an octal mode such as 755 or 4755, an ls -l string such as rwxr-x---, or tick the boxes.

What you type is calculated only in your browser and is not sent to a server.

Permission bits
Read rWrite wExecute xSpecial
Owner (u) setuid
Group (g) setgid
Others (o) sticky
Octal (stat -c %a)755
ls -l / stat -c %A-rwxr-xr-x
Commandchmod 755 file
Same aschmod u=rwx,g=rx,o=rx file

Apply a chmod expression

umask → new files and directories

New files start from 666 and directories from 777; the bits set in the umask are removed. Programs may ask for less (a compiler gives 777 to executables).

What it does

Converts between an octal mode, an ls -l string and checkboxes. The second box applies a chmod expression to a current mode, and the last one shows what a umask gives new files and directories. The rules are a port of GNU coreutils chmod.

Examples

InputResult
755rwxr-xr-x — owner everything, others read and execute
640rw-r----- — common for config files
4755rwsr-xr-x — setuid (programs like passwd)
1777 (directory)drwxrwxrwt — a shared directory like /tmp where users cannot delete each other's files
u+x,g-w on 644744
+w on 644 (umask 022)644 — without a, bits set in the umask (group and other write) are skipped. a+w gives 666
umask 027new file 640 · new directory 750

Common mistakes

  • Removing x from directories — on a directory x means "enter". Running chmod -R 644 over a tree makes the files inside unreachable. For mixed trees use capital X (execute only for directories or files that already have it): chmod -R u=rwX,go=rX.
  • Hiding a problem with 777 — a web server 403 is usually a missing x on a parent directory or the wrong owner. 777 lets anyone change the files.
  • setgid on a directory will not go away — GNU chmod 755 dir keeps an existing setgid. Use chmod g-s dir or the 5-digit 00755.

How it was checked

Before publishing, 286 checks were run with GNU coreutils 9.4 chmod, stat -c '%a %A' and bash umask plus touch/mkdir on this server: 20 octal modes on files and directories, 37 expressions on files and directories under umask 022 and 027, 8 expressions chmod rejects and 10 umask values. That includes the cases where chmod warns and exits with status 1 because of the umask.

FAQ

Is 755 different from 0755?

No, they behave the same on files and directories; the leading 0 just says "no special bits". On directories, though, GNU chmod does not clear setuid or setgid with a numeric mode of up to four digits, so both keep an existing setgid. Write five digits, 00755, to clear it.

My umask is 022, so why are new files 644 and not 755?

New files usually start from 666 (they are created without execute bits); removing 022 gives 644. Directories start from 777 and end up 755. A umask only removes bits, it never adds them.

Is what I type sent to a server?

No. Everything is calculated in your browser. Input is not sent to a server and is not passed to the analytics or ads this site uses. See the privacy notice.