<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: authur</title>
    <description>The latest articles on DEV Community by authur (@authur_e41405d48d93d6de98).</description>
    <link>https://dev.to/authur_e41405d48d93d6de98</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3938171%2F127c456a-3961-46dd-8688-a00e6e6cf0aa.png</url>
      <title>DEV Community: authur</title>
      <link>https://dev.to/authur_e41405d48d93d6de98</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/authur_e41405d48d93d6de98"/>
    <language>en</language>
    <item>
      <title>Why umask 022 creates 755 folders and 644 files</title>
      <dc:creator>authur</dc:creator>
      <pubDate>Mon, 18 May 2026 13:23:49 +0000</pubDate>
      <link>https://dev.to/authur_e41405d48d93d6de98/why-umask-022-creates-755-folders-and-644-files-1n2j</link>
      <guid>https://dev.to/authur_e41405d48d93d6de98/why-umask-022-creates-755-folders-and-644-files-1n2j</guid>
      <description>&lt;p&gt;If you have ever wondered why &lt;code&gt;umask 022&lt;/code&gt; creates directories like &lt;code&gt;755&lt;/code&gt; but files like &lt;code&gt;644&lt;/code&gt;, the short answer is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;directories start from 777
regular files usually start from 666
umask subtracts permissions from those defaults
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So &lt;code&gt;022&lt;/code&gt; does not mean "set permissions to 022". It means "remove these permission bits from the default mode".&lt;/p&gt;

&lt;h2&gt;
  
  
  The common example
&lt;/h2&gt;

&lt;p&gt;For directories:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;777 - 022 = 755
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For regular files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;666 - 022 = 644
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is why a newly created folder often becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drwxr-xr-x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And a newly created file often becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-rw-r--r--
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why files do not start from 777
&lt;/h2&gt;

&lt;p&gt;Directories need the execute bit so users can enter and traverse them.&lt;/p&gt;

&lt;p&gt;Regular files usually do not start as executable. That is why the default starting point for many newly created files is &lt;code&gt;666&lt;/code&gt;, not &lt;code&gt;777&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So this is expected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;umask 022 -&amp;gt; folders 755
umask 022 -&amp;gt; files 644
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  More examples
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;umask 002 -&amp;gt; folders 775, files 664
umask 027 -&amp;gt; folders 750, files 640
umask 077 -&amp;gt; folders 700, files 600
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;002&lt;/code&gt; is common when a shared group needs write access.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;027&lt;/code&gt; is stricter: group can read and enter directories, but others get no access.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;077&lt;/code&gt; is private: only the owner gets access.&lt;/p&gt;

&lt;h2&gt;
  
  
  chmod vs umask
&lt;/h2&gt;

&lt;p&gt;A lot of confusion comes from mixing up &lt;code&gt;chmod&lt;/code&gt; and &lt;code&gt;umask&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chmod&lt;/code&gt; changes permissions on existing files or directories.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;umask&lt;/code&gt; controls the default permissions for new files and directories.&lt;/p&gt;

&lt;p&gt;So if a file already exists, changing your umask will not change that file. You would use &lt;code&gt;chmod&lt;/code&gt; for that.&lt;/p&gt;

&lt;p&gt;If new files are being created with the wrong permissions, then checking the current umask makes sense.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick checklist
&lt;/h2&gt;

&lt;p&gt;When debugging a permissions problem, check these in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What user is creating the file?&lt;/li&gt;
&lt;li&gt;What group owns the parent directory?&lt;/li&gt;
&lt;li&gt;What is the current umask?&lt;/li&gt;
&lt;li&gt;Is the filesystem a normal Linux filesystem, or something mounted with options like &lt;code&gt;uid&lt;/code&gt;, &lt;code&gt;gid&lt;/code&gt;, &lt;code&gt;umask&lt;/code&gt;, &lt;code&gt;fmask&lt;/code&gt;, or &lt;code&gt;dmask&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;Are you trying to fix an existing file, or the defaults for future files?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That last question usually tells you whether you need &lt;code&gt;chmod&lt;/code&gt; or &lt;code&gt;umask&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I made a small browser-local calculator for this because I kept checking the same examples repeatedly:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://webutilslab.com/umask-calculator/?ref=devto" rel="noopener noreferrer"&gt;https://webutilslab.com/umask-calculator/?ref=devto&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It runs in the browser and is mostly useful for quickly verifying cases like &lt;code&gt;022&lt;/code&gt;, &lt;code&gt;027&lt;/code&gt;, and &lt;code&gt;077&lt;/code&gt;. &lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>tutorial</category>
      <category>security</category>
    </item>
  </channel>
</rss>
