[{"data":1,"prerenderedAt":734},["ShallowReactive",2],{"guide-understanding-umask-default-permissions":3},{"id":4,"title":5,"body":6,"date":722,"description":723,"extension":724,"meta":725,"navigation":344,"path":729,"readingTime":730,"seo":731,"stem":732,"__hash__":733},"guides\u002Fguides\u002Funderstanding-umask-default-permissions.md","Understanding umask and Default Permissions on Linux",{"type":7,"value":8,"toc":702},"minimark",[9,14,23,39,43,48,51,69,72,76,82,92,154,163,211,214,218,306,310,314,366,370,405,408,412,415,461,465,476,480,540,543,547,554,560,600,604,607,638,641,645,665,669,678,682,698],[10,11,13],"h2",{"id":12},"what-is-umask","What Is umask?",[15,16,17,18,22],"p",{},"When you create a new file or directory on Linux, the system assigns it default permissions. The ",[19,20,21],"strong",{},"umask"," (user file-creation mode mask) determines what those defaults are by subtracting permission bits from the base creation mode.",[15,24,25,26,30,31,34,35,38],{},"A umask of ",[27,28,29],"code",{},"022"," means newly created files get ",[27,32,33],{},"644"," (rw-r--r--) and directories get ",[27,36,37],{},"755"," (rwxr-xr-x). The umask does not grant permissions — it removes them.",[10,40,42],{"id":41},"how-umask-calculation-works","How umask Calculation Works",[44,45,47],"h3",{"id":46},"base-creation-modes","Base Creation Modes",[15,49,50],{},"Programs request permissions when creating files:",[52,53,54,62],"ul",{},[55,56,57,58,61],"li",{},"Files: base mode ",[27,59,60],{},"0666"," (rw-rw-rw-)",[55,63,64,65,68],{},"Directories: base mode ",[27,66,67],{},"0777"," (rwxrwxrwx)",[15,70,71],{},"The umask subtracts bits from these base values.",[44,73,75],{"id":74},"subtraction-example","Subtraction Example",[15,77,78,79,81],{},"With umask ",[27,80,29],{},":",[15,83,84,87,88,91],{},[19,85,86],{},"File:"," ",[27,89,90],{},"0666 - 0022 = 0644"," (rw-r--r--)",[93,94,95,113],"table",{},[96,97,98],"thead",{},[99,100,101,105,108,110],"tr",{},[102,103,104],"th",{},"Category",[102,106,107],{},"Base",[102,109,21],{},[102,111,112],{},"Result",[114,115,116,130,143],"tbody",{},[99,117,118,122,125,128],{},[119,120,121],"td",{},"Owner",[119,123,124],{},"rw-",[119,126,127],{},"---",[119,129,124],{},[99,131,132,135,137,140],{},[119,133,134],{},"Group",[119,136,124],{},[119,138,139],{},"-w-",[119,141,142],{},"r--",[99,144,145,148,150,152],{},[119,146,147],{},"Others",[119,149,124],{},[119,151,139],{},[119,153,142],{},[15,155,156,87,159,162],{},[19,157,158],{},"Directory:",[27,160,161],{},"0777 - 0022 = 0755"," (rwxr-xr-x)",[93,164,165,177],{},[96,166,167],{},[99,168,169,171,173,175],{},[102,170,104],{},[102,172,107],{},[102,174,21],{},[102,176,112],{},[114,178,179,190,201],{},[99,180,181,183,186,188],{},[119,182,121],{},[119,184,185],{},"rwx",[119,187,127],{},[119,189,185],{},[99,191,192,194,196,198],{},[119,193,134],{},[119,195,185],{},[119,197,139],{},[119,199,200],{},"r-x",[99,202,203,205,207,209],{},[119,204,147],{},[119,206,185],{},[119,208,139],{},[119,210,200],{},[15,212,213],{},"Note that umask uses the same octal values as chmod: read=4, write=2, execute=1.",[10,215,217],{"id":216},"common-umask-values","Common umask Values",[93,219,220,235],{},[96,221,222],{},[99,223,224,226,229,232],{},[102,225,21],{},[102,227,228],{},"File Permissions",[102,230,231],{},"Directory Permissions",[102,233,234],{},"Use Case",[114,236,237,250,264,278,292],{},[99,238,239,241,244,247],{},[119,240,29],{},[119,242,243],{},"644 (rw-r--r--)",[119,245,246],{},"755 (rwxr-xr-x)",[119,248,249],{},"Default on most Linux systems",[99,251,252,255,258,261],{},[119,253,254],{},"027",[119,256,257],{},"640 (rw-r-----)",[119,259,260],{},"750 (rwxr-x---)",[119,262,263],{},"More restrictive group access",[99,265,266,269,272,275],{},[119,267,268],{},"077",[119,270,271],{},"600 (rw-------)",[119,273,274],{},"700 (rwx------)",[119,276,277],{},"Private: no group or others access",[99,279,280,283,286,289],{},[119,281,282],{},"002",[119,284,285],{},"664 (rw-rw-r--)",[119,287,288],{},"775 (rwxrwxr-x)",[119,290,291],{},"Shared group collaboration",[99,293,294,297,300,303],{},[119,295,296],{},"000",[119,298,299],{},"666 (rw-rw-rw-)",[119,301,302],{},"777 (rwxrwxrwx)",[119,304,305],{},"No restrictions (dangerous)",[10,307,309],{"id":308},"checking-and-setting-umask","Checking and Setting umask",[44,311,313],{"id":312},"check-current-umask","Check Current umask",[315,316,321],"pre",{"className":317,"code":318,"language":319,"meta":320,"style":320},"language-bash shiki shiki-themes github-light github-dark","umask\n# Output: 0022\n\n# Symbolic output (more readable)\numask -S\n# Output: u=rwx,g=rx,o=rx\n","bash","",[27,322,323,332,339,346,352,360],{"__ignoreMap":320},[324,325,328],"span",{"class":326,"line":327},"line",1,[324,329,331],{"class":330},"sj4cs","umask\n",[324,333,335],{"class":326,"line":334},2,[324,336,338],{"class":337},"sJ8bj","# Output: 0022\n",[324,340,342],{"class":326,"line":341},3,[324,343,345],{"emptyLinePlaceholder":344},true,"\n",[324,347,349],{"class":326,"line":348},4,[324,350,351],{"class":337},"# Symbolic output (more readable)\n",[324,353,355,357],{"class":326,"line":354},5,[324,356,21],{"class":330},[324,358,359],{"class":330}," -S\n",[324,361,363],{"class":326,"line":362},6,[324,364,365],{"class":337},"# Output: u=rwx,g=rx,o=rx\n",[44,367,369],{"id":368},"set-umask-temporarily","Set umask Temporarily",[315,371,373],{"className":317,"code":372,"language":319,"meta":320,"style":320},"# More restrictive for this session\numask 077\n\n# Verify\numask\n# Output: 0077\n",[27,374,375,380,387,391,396,400],{"__ignoreMap":320},[324,376,377],{"class":326,"line":327},[324,378,379],{"class":337},"# More restrictive for this session\n",[324,381,382,384],{"class":326,"line":334},[324,383,21],{"class":330},[324,385,386],{"class":330}," 077\n",[324,388,389],{"class":326,"line":341},[324,390,345],{"emptyLinePlaceholder":344},[324,392,393],{"class":326,"line":348},[324,394,395],{"class":337},"# Verify\n",[324,397,398],{"class":326,"line":354},[324,399,331],{"class":330},[324,401,402],{"class":326,"line":362},[324,403,404],{"class":337},"# Output: 0077\n",[15,406,407],{},"This change lasts only for the current shell session.",[44,409,411],{"id":410},"set-umask-permanently","Set umask Permanently",[15,413,414],{},"Add the umask command to your shell configuration:",[315,416,418],{"className":317,"code":417,"language":319,"meta":320,"style":320},"# For bash\necho \"umask 027\" >> ~\u002F.bashrc\n\n# For zsh\necho \"umask 027\" >> ~\u002F.zshrc\n",[27,419,420,425,441,445,450],{"__ignoreMap":320},[324,421,422],{"class":326,"line":327},[324,423,424],{"class":337},"# For bash\n",[324,426,427,430,434,438],{"class":326,"line":334},[324,428,429],{"class":330},"echo",[324,431,433],{"class":432},"sZZnC"," \"umask 027\"",[324,435,437],{"class":436},"szBVR"," >>",[324,439,440],{"class":432}," ~\u002F.bashrc\n",[324,442,443],{"class":326,"line":341},[324,444,345],{"emptyLinePlaceholder":344},[324,446,447],{"class":326,"line":348},[324,448,449],{"class":337},"# For zsh\n",[324,451,452,454,456,458],{"class":326,"line":354},[324,453,429],{"class":330},[324,455,433],{"class":432},[324,457,437],{"class":436},[324,459,460],{"class":432}," ~\u002F.zshrc\n",[44,462,464],{"id":463},"system-wide-default","System-Wide Default",[15,466,467,468,471,472,475],{},"The system default is typically set in ",[27,469,470],{},"\u002Fetc\u002Fprofile"," or ",[27,473,474],{},"\u002Fetc\u002Flogin.defs",". Changing this affects all users.",[10,477,479],{"id":478},"umask-vs-chmod","umask vs chmod",[93,481,482,494],{},[96,483,484],{},[99,485,486,489,491],{},[102,487,488],{},"Aspect",[102,490,21],{},[102,492,493],{},"chmod",[114,495,496,507,518,529],{},[99,497,498,501,504],{},[119,499,500],{},"When it applies",[119,502,503],{},"When files\u002Fdirectories are created",[119,505,506],{},"On existing files\u002Fdirectories",[99,508,509,512,515],{},[119,510,511],{},"Direction",[119,513,514],{},"Removes permissions from base",[119,516,517],{},"Sets permissions directly",[99,519,520,523,526],{},[119,521,522],{},"Persistence",[119,524,525],{},"Affects all future creations in session",[119,527,528],{},"One-time change on target",[99,530,531,534,537],{},[119,532,533],{},"Scope",[119,535,536],{},"Process-level setting",[119,538,539],{},"File-level setting",[15,541,542],{},"Use umask to set policy for new files. Use chmod to fix permissions on existing files.",[10,544,546],{"id":545},"special-permission-bits","Special Permission Bits",[15,548,549,550,553],{},"The umask can also affect setuid (4), setgid (2), and sticky bit (1). A four-digit umask like ",[27,551,552],{},"0022"," includes the special bits mask as the first digit.",[15,555,556,557,559],{},"Most users never need to adjust these via umask. The special bits are typically set with ",[27,558,493],{}," after creation:",[315,561,563],{"className":317,"code":562,"language":319,"meta":320,"style":320},"# Set setgid on a directory (new files inherit group)\nchmod 2775 \u002Fshared\u002Fproject\n\n# Set sticky bit on a directory (only owner can delete files)\nchmod 1777 \u002Ftmp\n",[27,564,565,570,581,585,590],{"__ignoreMap":320},[324,566,567],{"class":326,"line":327},[324,568,569],{"class":337},"# Set setgid on a directory (new files inherit group)\n",[324,571,572,575,578],{"class":326,"line":334},[324,573,493],{"class":574},"sScJk",[324,576,577],{"class":330}," 2775",[324,579,580],{"class":432}," \u002Fshared\u002Fproject\n",[324,582,583],{"class":326,"line":341},[324,584,345],{"emptyLinePlaceholder":344},[324,586,587],{"class":326,"line":348},[324,588,589],{"class":337},"# Set sticky bit on a directory (only owner can delete files)\n",[324,591,592,594,597],{"class":326,"line":354},[324,593,493],{"class":574},[324,595,596],{"class":330}," 1777",[324,598,599],{"class":432}," \u002Ftmp\n",[10,601,603],{"id":602},"web-server-considerations","Web Server Considerations",[15,605,606],{},"For web servers, umask directly affects security:",[315,608,610],{"className":317,"code":609,"language":319,"meta":320,"style":320},"# Secure umask for web deployments\numask 027\n\n# Result: files created as 640 (owner rw, group r, others nothing)\n# Directories created as 750 (owner rwx, group rx, others nothing)\n",[27,611,612,617,624,628,633],{"__ignoreMap":320},[324,613,614],{"class":326,"line":327},[324,615,616],{"class":337},"# Secure umask for web deployments\n",[324,618,619,621],{"class":326,"line":334},[324,620,21],{"class":330},[324,622,623],{"class":330}," 027\n",[324,625,626],{"class":326,"line":341},[324,627,345],{"emptyLinePlaceholder":344},[324,629,630],{"class":326,"line":348},[324,631,632],{"class":337},"# Result: files created as 640 (owner rw, group r, others nothing)\n",[324,634,635],{"class":326,"line":354},[324,636,637],{"class":337},"# Directories created as 750 (owner rwx, group rx, others nothing)\n",[15,639,640],{},"This prevents the \"others\" category from reading web files — the web server runs as the owner or group, while other system users have no access.",[10,642,644],{"id":643},"key-takeaways","Key Takeaways",[52,646,647,650,653,656,659,662],{},[55,648,649],{},"umask subtracts permission bits from the base creation mode (0666 for files, 0777 for directories)",[55,651,652],{},"Default umask 022 produces files at 644 and directories at 755",[55,654,655],{},"Set umask 077 for private environments, 027 for restricted group access, 002 for shared collaboration",[55,657,658],{},"umask affects only new files; use chmod for existing ones",[55,660,661],{},"Add umask to shell config files for persistent settings",[55,663,664],{},"Web servers should use restrictive umask values (027 or 077) to limit file exposure",[10,666,668],{"id":667},"try-it-yourself","Try It Yourself",[15,670,671,672,677],{},"Calculate permission values and understand the relationship between umask and chmod using our ",[673,674,676],"a",{"href":675},"\u002Ftools\u002Fchmod-calculator","chmod Calculator",". Toggle permission bits interactively and see numeric, symbolic, and binary representations side by side.",[10,679,681],{"id":680},"related-guides","Related Guides",[52,683,684,691],{},[55,685,686,690],{},[673,687,689],{"href":688},"\u002Fguides\u002Fchmod-guide","chmod Guide"," — complete reference for the chmod command",[55,692,693,697],{},[673,694,696],{"href":695},"\u002Fguides\u002Flinux-file-permissions","Linux File Permissions"," — deep dive into the owner\u002Fgroup\u002Fothers model",[699,700,701],"style",{},"html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}",{"title":320,"searchDepth":334,"depth":334,"links":703},[704,705,709,710,716,717,718,719,720,721],{"id":12,"depth":334,"text":13},{"id":41,"depth":334,"text":42,"children":706},[707,708],{"id":46,"depth":341,"text":47},{"id":74,"depth":341,"text":75},{"id":216,"depth":334,"text":217},{"id":308,"depth":334,"text":309,"children":711},[712,713,714,715],{"id":312,"depth":341,"text":313},{"id":368,"depth":341,"text":369},{"id":410,"depth":341,"text":411},{"id":463,"depth":341,"text":464},{"id":478,"depth":334,"text":479},{"id":545,"depth":334,"text":546},{"id":602,"depth":334,"text":603},{"id":643,"depth":334,"text":644},{"id":667,"depth":334,"text":668},{"id":680,"depth":334,"text":681},"2026-05-28","Learn how umask controls default file and directory permissions on Linux. Understand octal calculation, common umask values, and configuration.","md",{"keywords":726,"immutable":344},[727,728],"chmod-calculator","understanding-umask-default-permissions","\u002Fguides\u002Funderstanding-umask-default-permissions",7,{"title":5,"description":723},"guides\u002Funderstanding-umask-default-permissions","vAOfRBNcO6Gu59tnZ2-h3vFgOirBxLKXxiNPj9lJ0jU",1780401337747]