umask
Permissions
Usage
umask 022Decides which permission bits are withheld from newly created files; it subtracts rather than grants, so 022 yields 644 for files and 755 for directories, and it never touches files that already exist.
Common flags
| Flag | Meaning |
|---|---|
| 022 | The bits to withhold: files become 644, directories 755 |
| 077 | Nothing for group or others: files 600, directories 700 |
| -S | Show the mask as u=rwx,g=rx,o=rx instead of a number |
| -p | Print it in a form a script can reuse |
Examples
umaskPrints the current mask, usually 022.
umask 077New files become readable by you alone.
umask -SThe same mask in symbolic form.
Numeric and symbolic modes name the same thing: 755 and u=rwx,go=rx are the same permission.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does umask do?
Decides which permission bits are withheld from newly created files; it subtracts rather than grants, so 022 yields 644 for files and 755 for directories, and it never touches files that already exist.
Q. How do I type it?
umask 022 — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
4 are listed here; the full set is in man umask. This command sits under Permissions.
Related commands
man page: man umask