ChmodCalc

umask Calculator

umask 022 gives 644 files and 755 directories; umask 077 gives 600 and 700. A umask does not set permissions — it takes them away from whatever a program asked for, which is why no umask can make a file executable. The complete table of all 512 values is below.

chmod — file mode
whoreadwriteexecutedigit
Owner6
Group4
Others4
special bits — the fourth digit

ls -l → -rw-r--r--

chmod 644 newfile.txt
chmod u=rw,g=r,o=r newfile.txt

Absolute symbolic form — identical result, and the only form that can name the setuid, setgid and sticky bits.

chmod go-w newfile.txt

Relative form: what changed from 666. It leaves every other bit alone, which is what you want on a file you did not create.

what 644 grants on this file

  • Ownerrw-read the contents and change the contents
  • Groupr--read the contents
  • Othersr--read the contents

programs that refuse this mode

  • OpenSSH client (ssh, scp, sftp, git over ssh)

    Permissions 0644 for 'newfile.txt' are too open.

    fix: chmod 600 newfile.txt

  • Git

    hint: The 'newfile.txt' hook was ignored because it's not set as executable.

    fix: chmod +x newfile.txt

  • Any POSIX shell (bash, dash, zsh, sh)

    newfile.txt: Permission denied (exit status 126)

    fix: chmod +x newfile.txt

The rule, in one sentence

Permission bit positions that are set in cmask are cleared in the mode of the created file.

POSIX.1-2024 (IEEE Std 1003.1-2024), XSH umask() — DESCRIPTION. The Open Group’s own free HTML edition, read directly.

Everything else follows from that. A umask is a set of bits to remove, applied to the mode the creating program requested — not to some notional default. The two requests that matter in practice are 0666, which is what tools ask for when creating an ordinary file, and 0777, which is what mkdir asks for. So:

file mode      = 0666 AND NOT umask
directory mode = 0777 AND NOT umask

The consequence people trip over: because the file base is 0666 and that has no execute bits, no umask value can produce an executable file. A umask of 000 gives you 666, not 777. If your build system is producing non-executable scripts, the umask is not the lever — the tool creating them is.

The values worth knowing

Each row's file and directory columns are computed by applying the rule above, not copied from a reference. The "what it does" column describes the arithmetic only — it deliberately makes no claim about which distribution ships which default, because that is a moving target and not something this page verified.
umask New files New directories What it does
000 666 rw-rw-rw- 777 rwxrwxrwx removes nothing: new files land at 666 and new directories at 777
002 664 rw-rw-r-- 775 rwxrwxr-x removes write from others only — the shared-group setting
022 644 rw-r--r-- 755 rwxr-xr-x removes write from group and others: files 644, directories 755
027 640 rw-r----- 750 rwxr-x--- as 022, and removes everything from others: files 640, directories 750
077 600 rw------- 700 rwx------ removes everything from group and others: files 600, directories 700
007 660 rw-rw---- 770 rwxrwx--- leaves the group full access, removes everything from others
777 000 --------- 000 --------- removes every bit: new files arrive at 000 and are unreadable even by their owner

All 512 values

Eight blocks of 64, keyed on the first digit of the umask. Every value from 000 to 777 is present; none is skipped and none is summarised.

0xx — 64 umask values
umask File rwx Directory rwx
000 666 rw-rw-rw- 777 rwxrwxrwx
001 666 rw-rw-rw- 776 rwxrwxrw-
002 664 rw-rw-r-- 775 rwxrwxr-x
003 664 rw-rw-r-- 774 rwxrwxr--
004 662 rw-rw--w- 773 rwxrwx-wx
005 662 rw-rw--w- 772 rwxrwx-w-
006 660 rw-rw---- 771 rwxrwx--x
007 660 rw-rw---- 770 rwxrwx---
010 666 rw-rw-rw- 767 rwxrw-rwx
011 666 rw-rw-rw- 766 rwxrw-rw-
012 664 rw-rw-r-- 765 rwxrw-r-x
013 664 rw-rw-r-- 764 rwxrw-r--
014 662 rw-rw--w- 763 rwxrw--wx
015 662 rw-rw--w- 762 rwxrw--w-
016 660 rw-rw---- 761 rwxrw---x
017 660 rw-rw---- 760 rwxrw----
020 646 rw-r--rw- 757 rwxr-xrwx
021 646 rw-r--rw- 756 rwxr-xrw-
022 644 rw-r--r-- 755 rwxr-xr-x
023 644 rw-r--r-- 754 rwxr-xr--
024 642 rw-r---w- 753 rwxr-x-wx
025 642 rw-r---w- 752 rwxr-x-w-
026 640 rw-r----- 751 rwxr-x--x
027 640 rw-r----- 750 rwxr-x---
030 646 rw-r--rw- 747 rwxr--rwx
031 646 rw-r--rw- 746 rwxr--rw-
032 644 rw-r--r-- 745 rwxr--r-x
033 644 rw-r--r-- 744 rwxr--r--
034 642 rw-r---w- 743 rwxr---wx
035 642 rw-r---w- 742 rwxr---w-
036 640 rw-r----- 741 rwxr----x
037 640 rw-r----- 740 rwxr-----
040 626 rw--w-rw- 737 rwx-wxrwx
041 626 rw--w-rw- 736 rwx-wxrw-
042 624 rw--w-r-- 735 rwx-wxr-x
043 624 rw--w-r-- 734 rwx-wxr--
044 622 rw--w--w- 733 rwx-wx-wx
045 622 rw--w--w- 732 rwx-wx-w-
046 620 rw--w---- 731 rwx-wx--x
047 620 rw--w---- 730 rwx-wx---
050 626 rw--w-rw- 727 rwx-w-rwx
051 626 rw--w-rw- 726 rwx-w-rw-
052 624 rw--w-r-- 725 rwx-w-r-x
053 624 rw--w-r-- 724 rwx-w-r--
054 622 rw--w--w- 723 rwx-w--wx
055 622 rw--w--w- 722 rwx-w--w-
056 620 rw--w---- 721 rwx-w---x
057 620 rw--w---- 720 rwx-w----
060 606 rw----rw- 717 rwx--xrwx
061 606 rw----rw- 716 rwx--xrw-
062 604 rw----r-- 715 rwx--xr-x
063 604 rw----r-- 714 rwx--xr--
064 602 rw-----w- 713 rwx--x-wx
065 602 rw-----w- 712 rwx--x-w-
066 600 rw------- 711 rwx--x--x
067 600 rw------- 710 rwx--x---
070 606 rw----rw- 707 rwx---rwx
071 606 rw----rw- 706 rwx---rw-
072 604 rw----r-- 705 rwx---r-x
073 604 rw----r-- 704 rwx---r--
074 602 rw-----w- 703 rwx----wx
075 602 rw-----w- 702 rwx----w-
076 600 rw------- 701 rwx-----x
077 600 rw------- 700 rwx------
1xx — 64 umask values
umask File rwx Directory rwx
100 666 rw-rw-rw- 677 rw-rwxrwx
101 666 rw-rw-rw- 676 rw-rwxrw-
102 664 rw-rw-r-- 675 rw-rwxr-x
103 664 rw-rw-r-- 674 rw-rwxr--
104 662 rw-rw--w- 673 rw-rwx-wx
105 662 rw-rw--w- 672 rw-rwx-w-
106 660 rw-rw---- 671 rw-rwx--x
107 660 rw-rw---- 670 rw-rwx---
110 666 rw-rw-rw- 667 rw-rw-rwx
111 666 rw-rw-rw- 666 rw-rw-rw-
112 664 rw-rw-r-- 665 rw-rw-r-x
113 664 rw-rw-r-- 664 rw-rw-r--
114 662 rw-rw--w- 663 rw-rw--wx
115 662 rw-rw--w- 662 rw-rw--w-
116 660 rw-rw---- 661 rw-rw---x
117 660 rw-rw---- 660 rw-rw----
120 646 rw-r--rw- 657 rw-r-xrwx
121 646 rw-r--rw- 656 rw-r-xrw-
122 644 rw-r--r-- 655 rw-r-xr-x
123 644 rw-r--r-- 654 rw-r-xr--
124 642 rw-r---w- 653 rw-r-x-wx
125 642 rw-r---w- 652 rw-r-x-w-
126 640 rw-r----- 651 rw-r-x--x
127 640 rw-r----- 650 rw-r-x---
130 646 rw-r--rw- 647 rw-r--rwx
131 646 rw-r--rw- 646 rw-r--rw-
132 644 rw-r--r-- 645 rw-r--r-x
133 644 rw-r--r-- 644 rw-r--r--
134 642 rw-r---w- 643 rw-r---wx
135 642 rw-r---w- 642 rw-r---w-
136 640 rw-r----- 641 rw-r----x
137 640 rw-r----- 640 rw-r-----
140 626 rw--w-rw- 637 rw--wxrwx
141 626 rw--w-rw- 636 rw--wxrw-
142 624 rw--w-r-- 635 rw--wxr-x
143 624 rw--w-r-- 634 rw--wxr--
144 622 rw--w--w- 633 rw--wx-wx
145 622 rw--w--w- 632 rw--wx-w-
146 620 rw--w---- 631 rw--wx--x
147 620 rw--w---- 630 rw--wx---
150 626 rw--w-rw- 627 rw--w-rwx
151 626 rw--w-rw- 626 rw--w-rw-
152 624 rw--w-r-- 625 rw--w-r-x
153 624 rw--w-r-- 624 rw--w-r--
154 622 rw--w--w- 623 rw--w--wx
155 622 rw--w--w- 622 rw--w--w-
156 620 rw--w---- 621 rw--w---x
157 620 rw--w---- 620 rw--w----
160 606 rw----rw- 617 rw---xrwx
161 606 rw----rw- 616 rw---xrw-
162 604 rw----r-- 615 rw---xr-x
163 604 rw----r-- 614 rw---xr--
164 602 rw-----w- 613 rw---x-wx
165 602 rw-----w- 612 rw---x-w-
166 600 rw------- 611 rw---x--x
167 600 rw------- 610 rw---x---
170 606 rw----rw- 607 rw----rwx
171 606 rw----rw- 606 rw----rw-
172 604 rw----r-- 605 rw----r-x
173 604 rw----r-- 604 rw----r--
174 602 rw-----w- 603 rw-----wx
175 602 rw-----w- 602 rw-----w-
176 600 rw------- 601 rw------x
177 600 rw------- 600 rw-------
2xx — 64 umask values
umask File rwx Directory rwx
200 466 r--rw-rw- 577 r-xrwxrwx
201 466 r--rw-rw- 576 r-xrwxrw-
202 464 r--rw-r-- 575 r-xrwxr-x
203 464 r--rw-r-- 574 r-xrwxr--
204 462 r--rw--w- 573 r-xrwx-wx
205 462 r--rw--w- 572 r-xrwx-w-
206 460 r--rw---- 571 r-xrwx--x
207 460 r--rw---- 570 r-xrwx---
210 466 r--rw-rw- 567 r-xrw-rwx
211 466 r--rw-rw- 566 r-xrw-rw-
212 464 r--rw-r-- 565 r-xrw-r-x
213 464 r--rw-r-- 564 r-xrw-r--
214 462 r--rw--w- 563 r-xrw--wx
215 462 r--rw--w- 562 r-xrw--w-
216 460 r--rw---- 561 r-xrw---x
217 460 r--rw---- 560 r-xrw----
220 446 r--r--rw- 557 r-xr-xrwx
221 446 r--r--rw- 556 r-xr-xrw-
222 444 r--r--r-- 555 r-xr-xr-x
223 444 r--r--r-- 554 r-xr-xr--
224 442 r--r---w- 553 r-xr-x-wx
225 442 r--r---w- 552 r-xr-x-w-
226 440 r--r----- 551 r-xr-x--x
227 440 r--r----- 550 r-xr-x---
230 446 r--r--rw- 547 r-xr--rwx
231 446 r--r--rw- 546 r-xr--rw-
232 444 r--r--r-- 545 r-xr--r-x
233 444 r--r--r-- 544 r-xr--r--
234 442 r--r---w- 543 r-xr---wx
235 442 r--r---w- 542 r-xr---w-
236 440 r--r----- 541 r-xr----x
237 440 r--r----- 540 r-xr-----
240 426 r---w-rw- 537 r-x-wxrwx
241 426 r---w-rw- 536 r-x-wxrw-
242 424 r---w-r-- 535 r-x-wxr-x
243 424 r---w-r-- 534 r-x-wxr--
244 422 r---w--w- 533 r-x-wx-wx
245 422 r---w--w- 532 r-x-wx-w-
246 420 r---w---- 531 r-x-wx--x
247 420 r---w---- 530 r-x-wx---
250 426 r---w-rw- 527 r-x-w-rwx
251 426 r---w-rw- 526 r-x-w-rw-
252 424 r---w-r-- 525 r-x-w-r-x
253 424 r---w-r-- 524 r-x-w-r--
254 422 r---w--w- 523 r-x-w--wx
255 422 r---w--w- 522 r-x-w--w-
256 420 r---w---- 521 r-x-w---x
257 420 r---w---- 520 r-x-w----
260 406 r-----rw- 517 r-x--xrwx
261 406 r-----rw- 516 r-x--xrw-
262 404 r-----r-- 515 r-x--xr-x
263 404 r-----r-- 514 r-x--xr--
264 402 r------w- 513 r-x--x-wx
265 402 r------w- 512 r-x--x-w-
266 400 r-------- 511 r-x--x--x
267 400 r-------- 510 r-x--x---
270 406 r-----rw- 507 r-x---rwx
271 406 r-----rw- 506 r-x---rw-
272 404 r-----r-- 505 r-x---r-x
273 404 r-----r-- 504 r-x---r--
274 402 r------w- 503 r-x----wx
275 402 r------w- 502 r-x----w-
276 400 r-------- 501 r-x-----x
277 400 r-------- 500 r-x------
3xx — 64 umask values
umask File rwx Directory rwx
300 466 r--rw-rw- 477 r--rwxrwx
301 466 r--rw-rw- 476 r--rwxrw-
302 464 r--rw-r-- 475 r--rwxr-x
303 464 r--rw-r-- 474 r--rwxr--
304 462 r--rw--w- 473 r--rwx-wx
305 462 r--rw--w- 472 r--rwx-w-
306 460 r--rw---- 471 r--rwx--x
307 460 r--rw---- 470 r--rwx---
310 466 r--rw-rw- 467 r--rw-rwx
311 466 r--rw-rw- 466 r--rw-rw-
312 464 r--rw-r-- 465 r--rw-r-x
313 464 r--rw-r-- 464 r--rw-r--
314 462 r--rw--w- 463 r--rw--wx
315 462 r--rw--w- 462 r--rw--w-
316 460 r--rw---- 461 r--rw---x
317 460 r--rw---- 460 r--rw----
320 446 r--r--rw- 457 r--r-xrwx
321 446 r--r--rw- 456 r--r-xrw-
322 444 r--r--r-- 455 r--r-xr-x
323 444 r--r--r-- 454 r--r-xr--
324 442 r--r---w- 453 r--r-x-wx
325 442 r--r---w- 452 r--r-x-w-
326 440 r--r----- 451 r--r-x--x
327 440 r--r----- 450 r--r-x---
330 446 r--r--rw- 447 r--r--rwx
331 446 r--r--rw- 446 r--r--rw-
332 444 r--r--r-- 445 r--r--r-x
333 444 r--r--r-- 444 r--r--r--
334 442 r--r---w- 443 r--r---wx
335 442 r--r---w- 442 r--r---w-
336 440 r--r----- 441 r--r----x
337 440 r--r----- 440 r--r-----
340 426 r---w-rw- 437 r---wxrwx
341 426 r---w-rw- 436 r---wxrw-
342 424 r---w-r-- 435 r---wxr-x
343 424 r---w-r-- 434 r---wxr--
344 422 r---w--w- 433 r---wx-wx
345 422 r---w--w- 432 r---wx-w-
346 420 r---w---- 431 r---wx--x
347 420 r---w---- 430 r---wx---
350 426 r---w-rw- 427 r---w-rwx
351 426 r---w-rw- 426 r---w-rw-
352 424 r---w-r-- 425 r---w-r-x
353 424 r---w-r-- 424 r---w-r--
354 422 r---w--w- 423 r---w--wx
355 422 r---w--w- 422 r---w--w-
356 420 r---w---- 421 r---w---x
357 420 r---w---- 420 r---w----
360 406 r-----rw- 417 r----xrwx
361 406 r-----rw- 416 r----xrw-
362 404 r-----r-- 415 r----xr-x
363 404 r-----r-- 414 r----xr--
364 402 r------w- 413 r----x-wx
365 402 r------w- 412 r----x-w-
366 400 r-------- 411 r----x--x
367 400 r-------- 410 r----x---
370 406 r-----rw- 407 r-----rwx
371 406 r-----rw- 406 r-----rw-
372 404 r-----r-- 405 r-----r-x
373 404 r-----r-- 404 r-----r--
374 402 r------w- 403 r------wx
375 402 r------w- 402 r------w-
376 400 r-------- 401 r-------x
377 400 r-------- 400 r--------
4xx — 64 umask values
umask File rwx Directory rwx
400 266 -w-rw-rw- 377 -wxrwxrwx
401 266 -w-rw-rw- 376 -wxrwxrw-
402 264 -w-rw-r-- 375 -wxrwxr-x
403 264 -w-rw-r-- 374 -wxrwxr--
404 262 -w-rw--w- 373 -wxrwx-wx
405 262 -w-rw--w- 372 -wxrwx-w-
406 260 -w-rw---- 371 -wxrwx--x
407 260 -w-rw---- 370 -wxrwx---
410 266 -w-rw-rw- 367 -wxrw-rwx
411 266 -w-rw-rw- 366 -wxrw-rw-
412 264 -w-rw-r-- 365 -wxrw-r-x
413 264 -w-rw-r-- 364 -wxrw-r--
414 262 -w-rw--w- 363 -wxrw--wx
415 262 -w-rw--w- 362 -wxrw--w-
416 260 -w-rw---- 361 -wxrw---x
417 260 -w-rw---- 360 -wxrw----
420 246 -w-r--rw- 357 -wxr-xrwx
421 246 -w-r--rw- 356 -wxr-xrw-
422 244 -w-r--r-- 355 -wxr-xr-x
423 244 -w-r--r-- 354 -wxr-xr--
424 242 -w-r---w- 353 -wxr-x-wx
425 242 -w-r---w- 352 -wxr-x-w-
426 240 -w-r----- 351 -wxr-x--x
427 240 -w-r----- 350 -wxr-x---
430 246 -w-r--rw- 347 -wxr--rwx
431 246 -w-r--rw- 346 -wxr--rw-
432 244 -w-r--r-- 345 -wxr--r-x
433 244 -w-r--r-- 344 -wxr--r--
434 242 -w-r---w- 343 -wxr---wx
435 242 -w-r---w- 342 -wxr---w-
436 240 -w-r----- 341 -wxr----x
437 240 -w-r----- 340 -wxr-----
440 226 -w--w-rw- 337 -wx-wxrwx
441 226 -w--w-rw- 336 -wx-wxrw-
442 224 -w--w-r-- 335 -wx-wxr-x
443 224 -w--w-r-- 334 -wx-wxr--
444 222 -w--w--w- 333 -wx-wx-wx
445 222 -w--w--w- 332 -wx-wx-w-
446 220 -w--w---- 331 -wx-wx--x
447 220 -w--w---- 330 -wx-wx---
450 226 -w--w-rw- 327 -wx-w-rwx
451 226 -w--w-rw- 326 -wx-w-rw-
452 224 -w--w-r-- 325 -wx-w-r-x
453 224 -w--w-r-- 324 -wx-w-r--
454 222 -w--w--w- 323 -wx-w--wx
455 222 -w--w--w- 322 -wx-w--w-
456 220 -w--w---- 321 -wx-w---x
457 220 -w--w---- 320 -wx-w----
460 206 -w----rw- 317 -wx--xrwx
461 206 -w----rw- 316 -wx--xrw-
462 204 -w----r-- 315 -wx--xr-x
463 204 -w----r-- 314 -wx--xr--
464 202 -w-----w- 313 -wx--x-wx
465 202 -w-----w- 312 -wx--x-w-
466 200 -w------- 311 -wx--x--x
467 200 -w------- 310 -wx--x---
470 206 -w----rw- 307 -wx---rwx
471 206 -w----rw- 306 -wx---rw-
472 204 -w----r-- 305 -wx---r-x
473 204 -w----r-- 304 -wx---r--
474 202 -w-----w- 303 -wx----wx
475 202 -w-----w- 302 -wx----w-
476 200 -w------- 301 -wx-----x
477 200 -w------- 300 -wx------
5xx — 64 umask values
umask File rwx Directory rwx
500 266 -w-rw-rw- 277 -w-rwxrwx
501 266 -w-rw-rw- 276 -w-rwxrw-
502 264 -w-rw-r-- 275 -w-rwxr-x
503 264 -w-rw-r-- 274 -w-rwxr--
504 262 -w-rw--w- 273 -w-rwx-wx
505 262 -w-rw--w- 272 -w-rwx-w-
506 260 -w-rw---- 271 -w-rwx--x
507 260 -w-rw---- 270 -w-rwx---
510 266 -w-rw-rw- 267 -w-rw-rwx
511 266 -w-rw-rw- 266 -w-rw-rw-
512 264 -w-rw-r-- 265 -w-rw-r-x
513 264 -w-rw-r-- 264 -w-rw-r--
514 262 -w-rw--w- 263 -w-rw--wx
515 262 -w-rw--w- 262 -w-rw--w-
516 260 -w-rw---- 261 -w-rw---x
517 260 -w-rw---- 260 -w-rw----
520 246 -w-r--rw- 257 -w-r-xrwx
521 246 -w-r--rw- 256 -w-r-xrw-
522 244 -w-r--r-- 255 -w-r-xr-x
523 244 -w-r--r-- 254 -w-r-xr--
524 242 -w-r---w- 253 -w-r-x-wx
525 242 -w-r---w- 252 -w-r-x-w-
526 240 -w-r----- 251 -w-r-x--x
527 240 -w-r----- 250 -w-r-x---
530 246 -w-r--rw- 247 -w-r--rwx
531 246 -w-r--rw- 246 -w-r--rw-
532 244 -w-r--r-- 245 -w-r--r-x
533 244 -w-r--r-- 244 -w-r--r--
534 242 -w-r---w- 243 -w-r---wx
535 242 -w-r---w- 242 -w-r---w-
536 240 -w-r----- 241 -w-r----x
537 240 -w-r----- 240 -w-r-----
540 226 -w--w-rw- 237 -w--wxrwx
541 226 -w--w-rw- 236 -w--wxrw-
542 224 -w--w-r-- 235 -w--wxr-x
543 224 -w--w-r-- 234 -w--wxr--
544 222 -w--w--w- 233 -w--wx-wx
545 222 -w--w--w- 232 -w--wx-w-
546 220 -w--w---- 231 -w--wx--x
547 220 -w--w---- 230 -w--wx---
550 226 -w--w-rw- 227 -w--w-rwx
551 226 -w--w-rw- 226 -w--w-rw-
552 224 -w--w-r-- 225 -w--w-r-x
553 224 -w--w-r-- 224 -w--w-r--
554 222 -w--w--w- 223 -w--w--wx
555 222 -w--w--w- 222 -w--w--w-
556 220 -w--w---- 221 -w--w---x
557 220 -w--w---- 220 -w--w----
560 206 -w----rw- 217 -w---xrwx
561 206 -w----rw- 216 -w---xrw-
562 204 -w----r-- 215 -w---xr-x
563 204 -w----r-- 214 -w---xr--
564 202 -w-----w- 213 -w---x-wx
565 202 -w-----w- 212 -w---x-w-
566 200 -w------- 211 -w---x--x
567 200 -w------- 210 -w---x---
570 206 -w----rw- 207 -w----rwx
571 206 -w----rw- 206 -w----rw-
572 204 -w----r-- 205 -w----r-x
573 204 -w----r-- 204 -w----r--
574 202 -w-----w- 203 -w-----wx
575 202 -w-----w- 202 -w-----w-
576 200 -w------- 201 -w------x
577 200 -w------- 200 -w-------
6xx — 64 umask values
umask File rwx Directory rwx
600 066 ---rw-rw- 177 --xrwxrwx
601 066 ---rw-rw- 176 --xrwxrw-
602 064 ---rw-r-- 175 --xrwxr-x
603 064 ---rw-r-- 174 --xrwxr--
604 062 ---rw--w- 173 --xrwx-wx
605 062 ---rw--w- 172 --xrwx-w-
606 060 ---rw---- 171 --xrwx--x
607 060 ---rw---- 170 --xrwx---
610 066 ---rw-rw- 167 --xrw-rwx
611 066 ---rw-rw- 166 --xrw-rw-
612 064 ---rw-r-- 165 --xrw-r-x
613 064 ---rw-r-- 164 --xrw-r--
614 062 ---rw--w- 163 --xrw--wx
615 062 ---rw--w- 162 --xrw--w-
616 060 ---rw---- 161 --xrw---x
617 060 ---rw---- 160 --xrw----
620 046 ---r--rw- 157 --xr-xrwx
621 046 ---r--rw- 156 --xr-xrw-
622 044 ---r--r-- 155 --xr-xr-x
623 044 ---r--r-- 154 --xr-xr--
624 042 ---r---w- 153 --xr-x-wx
625 042 ---r---w- 152 --xr-x-w-
626 040 ---r----- 151 --xr-x--x
627 040 ---r----- 150 --xr-x---
630 046 ---r--rw- 147 --xr--rwx
631 046 ---r--rw- 146 --xr--rw-
632 044 ---r--r-- 145 --xr--r-x
633 044 ---r--r-- 144 --xr--r--
634 042 ---r---w- 143 --xr---wx
635 042 ---r---w- 142 --xr---w-
636 040 ---r----- 141 --xr----x
637 040 ---r----- 140 --xr-----
640 026 ----w-rw- 137 --x-wxrwx
641 026 ----w-rw- 136 --x-wxrw-
642 024 ----w-r-- 135 --x-wxr-x
643 024 ----w-r-- 134 --x-wxr--
644 022 ----w--w- 133 --x-wx-wx
645 022 ----w--w- 132 --x-wx-w-
646 020 ----w---- 131 --x-wx--x
647 020 ----w---- 130 --x-wx---
650 026 ----w-rw- 127 --x-w-rwx
651 026 ----w-rw- 126 --x-w-rw-
652 024 ----w-r-- 125 --x-w-r-x
653 024 ----w-r-- 124 --x-w-r--
654 022 ----w--w- 123 --x-w--wx
655 022 ----w--w- 122 --x-w--w-
656 020 ----w---- 121 --x-w---x
657 020 ----w---- 120 --x-w----
660 006 ------rw- 117 --x--xrwx
661 006 ------rw- 116 --x--xrw-
662 004 ------r-- 115 --x--xr-x
663 004 ------r-- 114 --x--xr--
664 002 -------w- 113 --x--x-wx
665 002 -------w- 112 --x--x-w-
666 000 --------- 111 --x--x--x
667 000 --------- 110 --x--x---
670 006 ------rw- 107 --x---rwx
671 006 ------rw- 106 --x---rw-
672 004 ------r-- 105 --x---r-x
673 004 ------r-- 104 --x---r--
674 002 -------w- 103 --x----wx
675 002 -------w- 102 --x----w-
676 000 --------- 101 --x-----x
677 000 --------- 100 --x------
7xx — 64 umask values
umask File rwx Directory rwx
700 066 ---rw-rw- 077 ---rwxrwx
701 066 ---rw-rw- 076 ---rwxrw-
702 064 ---rw-r-- 075 ---rwxr-x
703 064 ---rw-r-- 074 ---rwxr--
704 062 ---rw--w- 073 ---rwx-wx
705 062 ---rw--w- 072 ---rwx-w-
706 060 ---rw---- 071 ---rwx--x
707 060 ---rw---- 070 ---rwx---
710 066 ---rw-rw- 067 ---rw-rwx
711 066 ---rw-rw- 066 ---rw-rw-
712 064 ---rw-r-- 065 ---rw-r-x
713 064 ---rw-r-- 064 ---rw-r--
714 062 ---rw--w- 063 ---rw--wx
715 062 ---rw--w- 062 ---rw--w-
716 060 ---rw---- 061 ---rw---x
717 060 ---rw---- 060 ---rw----
720 046 ---r--rw- 057 ---r-xrwx
721 046 ---r--rw- 056 ---r-xrw-
722 044 ---r--r-- 055 ---r-xr-x
723 044 ---r--r-- 054 ---r-xr--
724 042 ---r---w- 053 ---r-x-wx
725 042 ---r---w- 052 ---r-x-w-
726 040 ---r----- 051 ---r-x--x
727 040 ---r----- 050 ---r-x---
730 046 ---r--rw- 047 ---r--rwx
731 046 ---r--rw- 046 ---r--rw-
732 044 ---r--r-- 045 ---r--r-x
733 044 ---r--r-- 044 ---r--r--
734 042 ---r---w- 043 ---r---wx
735 042 ---r---w- 042 ---r---w-
736 040 ---r----- 041 ---r----x
737 040 ---r----- 040 ---r-----
740 026 ----w-rw- 037 ----wxrwx
741 026 ----w-rw- 036 ----wxrw-
742 024 ----w-r-- 035 ----wxr-x
743 024 ----w-r-- 034 ----wxr--
744 022 ----w--w- 033 ----wx-wx
745 022 ----w--w- 032 ----wx-w-
746 020 ----w---- 031 ----wx--x
747 020 ----w---- 030 ----wx---
750 026 ----w-rw- 027 ----w-rwx
751 026 ----w-rw- 026 ----w-rw-
752 024 ----w-r-- 025 ----w-r-x
753 024 ----w-r-- 024 ----w-r--
754 022 ----w--w- 023 ----w--wx
755 022 ----w--w- 022 ----w--w-
756 020 ----w---- 021 ----w---x
757 020 ----w---- 020 ----w----
760 006 ------rw- 017 -----xrwx
761 006 ------rw- 016 -----xrw-
762 004 ------r-- 015 -----xr-x
763 004 ------r-- 014 -----xr--
764 002 -------w- 013 -----x-wx
765 002 -------w- 012 -----x-w-
766 000 --------- 011 -----x--x
767 000 --------- 010 -----x---
770 006 ------rw- 007 ------rwx
771 006 ------rw- 006 ------rw-
772 004 ------r-- 005 ------r-x
773 004 ------r-- 004 ------r--
774 002 -------w- 003 -------wx
775 002 -------w- 002 -------w-
776 000 --------- 001 --------x
777 000 --------- 000 ---------

The file column repeats; the directory column does not

The two result columns behave differently, and the difference is worth a moment. There are 512 umask values and 512 distinct directory modes — one for each, a perfect one-to-one mapping, because the directory base 0777 contains every bit a umask could remove. But there are only 64 distinct file modes, because the file base 0666 has no execute bits, and a bit that is already absent cannot be removed again.

So every umask that differs only in its execute bits produces an identical file mode. umask 022 and umask 122 both give 644 files and differ only in the directory column, where the first yields 755 and the second 655.

That is a genuinely useful thing to notice when reading someone else's configuration. A umask with odd digits is doing something to directories and nothing to files, and is usually either deliberate and clever or copied and misunderstood.

Where to set it, and where that will not work

The mask is per-process and inherited by children, which makes "where do I set it" a question about process ancestry, not about configuration files. Three cases people get wrong:

  • A line in ~/.bashrc applies to interactive shells. It does not apply to a cron job, a systemd service, or anything a daemon spawns, because none of those is a child of your login shell.
  • A systemd service takes UMask= in its unit file. Setting it there is the only reliable way to control the modes that service creates; inheriting it from a shell profile will appear to work in testing and fail after a reboot.
  • Files that already exist are unaffected by any umask change, ever. Changing the mask changes what gets created next. Existing files need a chmod pass — typically the two find commands on the 755 page.

For a shared group directory, the umask and the setgid bit solve different halves of the same problem: chmod 2775 makes new entries inherit the directory's group, and umask 002 keeps the group-write bit from being masked off as they are created. Set one without the other and the collaboration still fails — with the setgid bit alone the group is right and the mode is read-only; with the umask alone the mode is right and the group is whoever happened to create the file.

One last check that costs nothing: run umask with no arguments in the exact context you care about. In a cron job that means putting umask in the job itself and reading the mail it sends. The value you assume is inherited very often is not.

## Questions people actually ask

What is umask?

A per-process mask that removes permission bits from files as they are created. POSIX states the rule in one sentence: “Permission bit positions that are set in cmask are cleared in the mode of the created file.” It only ever removes — it can never add a bit that the creating program did not ask for.

Why does umask 002 not make my new files executable?

Because the base mode is 0666, and 0666 has no execute bits to keep. Tools that create ordinary files ask the C library for read and write for all three classes and let the mask take bits away; a compiler that produces a binary asks for 0777 instead, which is why executables come out executable and your text files do not. No umask value can produce a file at 755 — the table below has no such row, because the arithmetic makes it impossible.

What umask gives 644 files and 755 directories?

022. That is the arithmetic: 0666 minus the group and other write bits is 644, and 0777 minus the same bits is 755. Whether it is also what your machine is set to is a separate question — run umask in the context you care about instead of assuming, because this page verified the arithmetic and not any system's configuration.

How do I set a umask permanently?

Where you set it depends on what should be affected, and getting this wrong is the usual failure. A line in your shell startup file affects interactive shells only — not cron jobs, not systemd services, not anything launched by a daemon. A service that must create files with a particular mode should have UMask= set in its unit, never left to an inherited value. Test it by creating a file the same way the real workload does, not by running touch in your terminal.

Does umask affect chmod?

No. chmod sets the mode you name, exactly, with no masking. umask applies only at creation time, to the mode the creating program requested. That is why a file created under one umask keeps its mode when the umask changes afterwards, and why "fix the umask" never repairs files that already exist — you need a chmod pass for those.

How many different file modes can a umask produce?

64, out of the 512 three-digit modes. The base mode fixes the ceiling, so the whole reachable set is the subsets of 0666. Directories reach 512 because their base is 0777. This is why the umask table is so much smaller than the mode table, and why several umask values map onto exactly the same result.

elsewhere on this site

other tools we run