<?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>Pressure Advance Calibration in Klipper: The Tuning Tower, the Math, and How to Read It</title>
      <dc:creator>authur</dc:creator>
      <pubDate>Wed, 03 Jun 2026 18:24:48 +0000</pubDate>
      <link>https://dev.to/authur_e41405d48d93d6de98/pressure-advance-calibration-in-klipper-the-tuning-tower-the-math-and-how-to-read-it-hhp</link>
      <guid>https://dev.to/authur_e41405d48d93d6de98/pressure-advance-calibration-in-klipper-the-tuning-tower-the-math-and-how-to-read-it-hhp</guid>
      <description>&lt;p&gt;If your prints have bulging corners, blobby seams, or thin gaps right after a fast move, you don't have an extrusion problem — you have a &lt;strong&gt;pressure&lt;/strong&gt; problem. The fix is &lt;strong&gt;pressure advance&lt;/strong&gt; (Klipper) or &lt;strong&gt;linear advance&lt;/strong&gt; (Marlin). This guide covers what it actually does, how to calibrate it with a tuning tower, and the small bit of math that turns the test into a final number.&lt;/p&gt;

&lt;h2&gt;
  
  
  What pressure advance actually does
&lt;/h2&gt;

&lt;p&gt;When the nozzle moves fast, pressure builds up in the melt zone. When it slows for a corner, that pressure keeps pushing plastic out for a moment — so the corner bulges. When it speeds back up, there's a brief under-extrusion gap. The extruder simply can't start and stop the flow instantly.&lt;/p&gt;

&lt;p&gt;Pressure advance tells the firmware to &lt;em&gt;advance&lt;/em&gt; (or relax) the extruder ahead of speed changes to cancel that lag. It does &lt;strong&gt;not&lt;/strong&gt; change how much filament is extruded overall — that's what &lt;code&gt;rotation_distance&lt;/code&gt; (Klipper) or E-steps (Marlin) and flow rate control. So calibrate those first; pressure advance is the layer on top.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tuning tower method
&lt;/h2&gt;

&lt;p&gt;Klipper has a neat trick: the &lt;code&gt;TUNING_TOWER&lt;/code&gt; command sweeps a parameter as the print gets taller, so a single object shows every value at once.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Slice a tall test model (the notched-cube PA test from the Klipper docs is ideal).&lt;/li&gt;
&lt;li&gt;Start the print, then run this in the console:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   TUNING_TOWER &lt;span class="nv"&gt;COMMAND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;SET_PRESSURE_ADVANCE &lt;span class="nv"&gt;PARAMETER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ADVANCE &lt;span class="nv"&gt;START&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 &lt;span class="nv"&gt;FACTOR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;.005
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;That starts &lt;code&gt;pressure_advance&lt;/code&gt; at 0 and adds 0.005 for every 1 mm of height.&lt;/li&gt;
&lt;li&gt;Let it print, then look for the height where corners are sharpest — no bulge before them, no gap after.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The math: turn a height into a value
&lt;/h2&gt;

&lt;p&gt;The value at any height is just:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pressure_advance = START + measured_height × FACTOR
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So if you used &lt;code&gt;START=0&lt;/code&gt; and &lt;code&gt;FACTOR=0.005&lt;/code&gt; and the cleanest band is at &lt;strong&gt;35 mm&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 + 35 × 0.005 = 0.175
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your &lt;code&gt;pressure_advance&lt;/code&gt; is &lt;strong&gt;0.175&lt;/strong&gt;. If you'd rather not do it by hand (or want a suggested FACTOR for a tighter second tower when the best band lands near the top or bottom), this free browser tool does exactly this: &lt;a href="https://3dprintcostcalc.top/calculators/pressure-advance-calculator/" rel="noopener noreferrer"&gt;Pressure Advance calculator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Apply the value in &lt;code&gt;printer.cfg&lt;/code&gt;, then &lt;code&gt;RESTART&lt;/code&gt; and reprint the test to confirm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[extruder]&lt;/span&gt;
&lt;span class="err"&gt;pressure_advance:&lt;/span&gt; &lt;span class="err"&gt;0.175&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reading the tower (the part people get wrong)
&lt;/h2&gt;

&lt;p&gt;You're not looking for "smooth walls" — you're looking at &lt;strong&gt;corners and direction changes&lt;/strong&gt;. Too little PA: corners bulge outward. Too much: corners get rounded and under-filled, and you see gaps. The sweet spot is the &lt;strong&gt;lowest&lt;/strong&gt; band where corners are crisp and consistent. Don't judge the seam or the first few layers — they're not representative.&lt;/p&gt;

&lt;p&gt;If the best result is at the very top or bottom of the tower, your range was off. Widen it, or use the suggested-factor approach to center a tighter second tower.&lt;/p&gt;

&lt;h2&gt;
  
  
  Direct drive vs Bowden
&lt;/h2&gt;

&lt;p&gt;The right value depends almost entirely on how far the filament has to travel:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Direct drive:&lt;/strong&gt; small, often &lt;strong&gt;0.02–0.08&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bowden:&lt;/strong&gt; much larger because of the tube, often &lt;strong&gt;0.3–1.0&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tube length, extruder gearing, temperature, and even the filament shift it, so never just copy someone else's number — run the tower.&lt;/p&gt;

&lt;h2&gt;
  
  
  Marlin users: linear advance
&lt;/h2&gt;

&lt;p&gt;Same idea, different name and command. Marlin calls it &lt;strong&gt;linear advance&lt;/strong&gt;, set with &lt;code&gt;M900 K&amp;lt;value&amp;gt;&lt;/code&gt; and saved with &lt;code&gt;M500&lt;/code&gt;. If you run a height-based tower, the formula above applies directly. If you print the classic labeled K-factor pattern instead, just read K off the cleanest line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;M900 K0.05
M500
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Order of operations
&lt;/h2&gt;

&lt;p&gt;Pressure advance only makes sense once extrusion is already accurate:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;rotation_distance&lt;/code&gt; / E-steps&lt;/strong&gt; — correct &lt;em&gt;length&lt;/em&gt; of filament fed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flow rate&lt;/strong&gt; — correct &lt;em&gt;amount&lt;/em&gt; in the wall.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pressure advance&lt;/strong&gt; — correct &lt;em&gt;pressure&lt;/em&gt; at corners. ← you are here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retraction&lt;/strong&gt; — kill stringing on travel moves.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Do it in that order, or you'll be chasing one error with another tool. If you want the math done for you, there are small browser calculators for &lt;a href="https://3dprintcostcalc.top/calculators/klipper-rotation-distance-calculator/" rel="noopener noreferrer"&gt;rotation_distance&lt;/a&gt;, &lt;a href="https://3dprintcostcalc.top/calculators/flow-rate-calculator/" rel="noopener noreferrer"&gt;flow rate&lt;/a&gt;, and &lt;a href="https://3dprintcostcalc.top/calculators/retraction-calculator/" rel="noopener noreferrer"&gt;retraction&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Bulging corners = pressure, not extrusion.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START=0 FACTOR=.005&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pressure_advance = START + height × FACTOR&lt;/code&gt; (e.g. 35 mm → 0.175).&lt;/li&gt;
&lt;li&gt;Direct drive ≈ 0.02–0.08, Bowden ≈ 0.3–1.0 — but always test.&lt;/li&gt;
&lt;li&gt;Calibrate extruder + flow first, retraction after.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy tuning — sharp corners await.&lt;/p&gt;

</description>
      <category>3dprinting</category>
      <category>klipper</category>
      <category>hacktoberfest23</category>
      <category>voron</category>
    </item>
    <item>
      <title>Klipper rotation_distance Calibration: A Step-by-Step Guide (With the Math)</title>
      <dc:creator>authur</dc:creator>
      <pubDate>Sun, 31 May 2026 19:58:47 +0000</pubDate>
      <link>https://dev.to/authur_e41405d48d93d6de98/klipper-rotationdistance-calibration-a-step-by-step-guide-with-the-math-jo6</link>
      <guid>https://dev.to/authur_e41405d48d93d6de98/klipper-rotationdistance-calibration-a-step-by-step-guide-with-the-math-jo6</guid>
      <description>&lt;p&gt;If you moved to Klipper from Marlin, the first thing that trips people up is that&lt;br&gt;
&lt;strong&gt;there are no E-steps&lt;/strong&gt;. Klipper describes the extruder with a single value called&lt;br&gt;
&lt;code&gt;rotation_distance&lt;/code&gt; — how many millimeters of filament move per full rotation of the&lt;br&gt;
extruder motor. Get it wrong and every print is silently over- or under-extruded, no&lt;br&gt;
matter how dialed-in your slicer is.&lt;/p&gt;

&lt;p&gt;This guide walks through calibrating it properly, including the formula so you&lt;br&gt;
understand &lt;em&gt;why&lt;/em&gt; it works rather than just copying numbers.&lt;/p&gt;
&lt;h2&gt;
  
  
  What rotation_distance actually means
&lt;/h2&gt;

&lt;p&gt;In your &lt;code&gt;printer.cfg&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[extruder]&lt;/span&gt;
&lt;span class="err"&gt;rotation_distance:&lt;/span&gt; &lt;span class="err"&gt;7.5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That &lt;code&gt;7.5&lt;/code&gt; means: one full turn of the extruder stepper should push 7.5 mm of&lt;br&gt;
filament. Klipper computes the step timing from this value plus your &lt;code&gt;microsteps&lt;/code&gt;&lt;br&gt;
and &lt;code&gt;full_steps_per_rotation&lt;/code&gt;, so you never touch steps/mm directly the way Marlin&lt;br&gt;
does. Calibrating the extruder = correcting this one number.&lt;/p&gt;
&lt;h2&gt;
  
  
  The calibration method: measure 100 mm of extrusion
&lt;/h2&gt;

&lt;p&gt;This is the same "mark and measure" routine every firmware uses; only the final&lt;br&gt;
math differs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Heat the hotend&lt;/strong&gt; to the normal printing temperature for your loaded filament,
so it extrudes freely without skipping.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mark the filament&lt;/strong&gt; at a fixed reference — e.g. exactly 120 mm above the
extruder inlet — with a marker or piece of tape.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Command a slow 100 mm extrusion.&lt;/strong&gt; Use relative mode so you don't have to track
absolute position:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   M83
   G1 E100 F100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Keep it slow (&lt;code&gt;F100&lt;/code&gt; = 100 mm/min). Fast extrusion skips steps and ruins the test.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Measure what actually moved.&lt;/strong&gt; Measure from your reference point again. If you
marked at 120 mm and now read 25 mm, the extruder pulled in 95 mm — it
&lt;strong&gt;under-extruded&lt;/strong&gt; by 5 mm.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  The formula
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new rotation_distance = current rotation_distance × (actual extrusion / commanded extrusion)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Worked example: current &lt;code&gt;rotation_distance&lt;/code&gt; is &lt;code&gt;7.5&lt;/code&gt;, you commanded &lt;code&gt;100 mm&lt;/code&gt;, and&lt;br&gt;
only &lt;code&gt;95 mm&lt;/code&gt; actually fed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;7.5 × (95 / 100) = 7.125
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So your corrected value is &lt;strong&gt;7.125&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Watch the direction — this is the #1 gotcha for Marlin migrants.&lt;/strong&gt;&lt;br&gt;
With Marlin E-steps, under-extrusion means you &lt;em&gt;raise&lt;/em&gt; steps/mm. With Klipper&lt;br&gt;
&lt;code&gt;rotation_distance&lt;/code&gt;, under-extrusion means you &lt;em&gt;lower&lt;/em&gt; the value. They're inverse&lt;br&gt;
quantities (mm-per-rotation vs steps-per-mm), so the correction goes the opposite&lt;br&gt;
way. If you mentally apply the E-steps direction here, you'll double your error.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you'd rather not do this by hand (or want to sanity-check the direction), this&lt;br&gt;
free browser tool does exactly this calculation and also converts an old Marlin&lt;br&gt;
steps/mm value into an equivalent Klipper &lt;code&gt;rotation_distance&lt;/code&gt;:&lt;br&gt;
&lt;a href="https://3dprintcostcalc.top/calculators/klipper-rotation-distance-calculator/" rel="noopener noreferrer"&gt;Klipper rotation_distance calculator&lt;/a&gt;.&lt;br&gt;
Coming from Marlin and want to see the E-steps side too? There's a matching&lt;br&gt;
&lt;a href="https://3dprintcostcalc.top/calculators/e-step-calculator/" rel="noopener noreferrer"&gt;E-steps calculator&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Apply the value
&lt;/h2&gt;

&lt;p&gt;Edit &lt;code&gt;printer.cfg&lt;/code&gt; manually — Klipper doesn't have a "save E-steps" G-code like&lt;br&gt;
Marlin's &lt;code&gt;M500&lt;/code&gt; for this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[extruder]&lt;/span&gt;
&lt;span class="err"&gt;rotation_distance:&lt;/span&gt; &lt;span class="err"&gt;7.125&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then &lt;code&gt;RESTART&lt;/code&gt; (or &lt;code&gt;FIRMWARE_RESTART&lt;/code&gt; if you changed pins) and &lt;strong&gt;re-run the 100 mm&lt;br&gt;
test&lt;/strong&gt;. If the first correction was large, expect to iterate once more — measurement&lt;br&gt;
error, filament slip, and a slightly cold nozzle all add noise. You're aiming for&lt;br&gt;
the measured value to land within ~0.5 mm of 100.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference starting points (for non-extruder axes)
&lt;/h2&gt;

&lt;p&gt;The same &lt;code&gt;rotation_distance&lt;/code&gt; concept governs your motion axes, and for those you can&lt;br&gt;
calculate the starting value instead of measuring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Belt axis:&lt;/strong&gt; &lt;code&gt;rotation_distance = belt_pitch × pulley_teeth&lt;/code&gt;
(e.g. 2 mm GT2 belt × 20-tooth pulley = 40)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leadscrew (Z):&lt;/strong&gt; &lt;code&gt;rotation_distance = screw_pitch × number_of_starts&lt;/code&gt;
(e.g. T8 with 4 starts at 2 mm pitch = 8)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are exact for motion axes; the extruder is the one that needs the&lt;br&gt;
measure-and-correct loop above because of filament grip variability.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to calibrate next
&lt;/h2&gt;

&lt;p&gt;Getting &lt;code&gt;rotation_distance&lt;/code&gt; right only guarantees the &lt;strong&gt;correct length&lt;/strong&gt; of filament&lt;br&gt;
is fed. It does not fix how much plastic ends up in the wall after squish and&lt;br&gt;
pressure. Once the extruder is accurate:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Flow rate / extrusion multiplier&lt;/strong&gt; — print a single-wall cube and measure the
wall with calipers. Tune it per filament in the slicer, not in firmware. A
&lt;a href="https://3dprintcostcalc.top/calculators/flow-rate-calculator/" rel="noopener noreferrer"&gt;flow rate calculator&lt;/a&gt;
handles the &lt;code&gt;new flow = current × expected_wall / measured_wall&lt;/code&gt; math.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pressure advance&lt;/strong&gt; — for sharp corners and consistent extrusion at speed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Volumetric flow ceiling&lt;/strong&gt; — make sure fast prints aren't outrunning your
hotend's melt rate.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Calibrate in that order. If you tune flow &lt;em&gt;before&lt;/em&gt; the extruder, the flow&lt;br&gt;
compensation just masks a wrong &lt;code&gt;rotation_distance&lt;/code&gt;, and you'll be chasing ghosts.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Klipper uses &lt;code&gt;rotation_distance&lt;/code&gt;, not E-steps.&lt;/li&gt;
&lt;li&gt;Measure a slow 100 mm extrusion, then
&lt;code&gt;new = current × actual / commanded&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Under-extrusion → &lt;strong&gt;lower&lt;/strong&gt; the value (opposite of Marlin).&lt;/li&gt;
&lt;li&gt;Edit &lt;code&gt;printer.cfg&lt;/code&gt;, &lt;code&gt;RESTART&lt;/code&gt;, re-measure, iterate.&lt;/li&gt;
&lt;li&gt;Then do flow → pressure advance → volumetric flow.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy printing — and may your extrusion multipliers be ever accurate.&lt;/p&gt;

</description>
      <category>3dprinting</category>
      <category>klipper</category>
      <category>voron</category>
    </item>
    <item>
      <title>umask vs chmod: why your new files keep getting the 'wrong' permissions</title>
      <dc:creator>authur</dc:creator>
      <pubDate>Sun, 31 May 2026 07:08:37 +0000</pubDate>
      <link>https://dev.to/authur_e41405d48d93d6de98/umask-vs-chmod-why-your-new-files-keep-getting-the-wrong-permissions-47g5</link>
      <guid>https://dev.to/authur_e41405d48d93d6de98/umask-vs-chmod-why-your-new-files-keep-getting-the-wrong-permissions-47g5</guid>
      <description>&lt;p&gt;If you've ever run &lt;code&gt;chmod&lt;/code&gt; to fix a file's permissions, created a new file five minutes later, and found it back at the "wrong" mode — you've met &lt;code&gt;umask&lt;/code&gt;. They look related, but they do different jobs, and confusing them causes a surprising amount of "why is this 644 again?" frustration.&lt;/p&gt;

&lt;p&gt;Here's the short version.&lt;/p&gt;

&lt;h2&gt;
  
  
  chmod changes permissions on files that already exist
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;chmod&lt;/code&gt; is reactive. It takes a file (or directory) that exists &lt;em&gt;right now&lt;/em&gt; and sets its mode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;640 secret.conf      &lt;span class="c"&gt;# rw-r----- on this one file&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;u+x deploy.sh        &lt;span class="c"&gt;# add execute for the owner&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. It does nothing for the &lt;em&gt;next&lt;/em&gt; file you create.&lt;/p&gt;

&lt;h2&gt;
  
  
  umask sets the default for files you haven't created yet
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;umask&lt;/code&gt; is proactive. It's a mask that gets &lt;strong&gt;subtracted&lt;/strong&gt; (bitwise) from the base permissions the OS hands out when something new is created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;New files start from &lt;code&gt;666&lt;/code&gt; (&lt;code&gt;rw-rw-rw-&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;New directories start from &lt;code&gt;777&lt;/code&gt; (&lt;code&gt;rwxrwxrwx&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The kernel then strips whatever bits your umask names.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;umask&lt;/span&gt;          &lt;span class="c"&gt;# show current mask, often 0022&lt;/span&gt;
&lt;span class="nb"&gt;umask &lt;/span&gt;027      &lt;span class="c"&gt;# set a stricter mask for this shell&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The relationship in one line
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final permission = base (666 file / 777 dir) AND (NOT umask)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So with the common &lt;code&gt;umask 022&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Created&lt;/th&gt;
&lt;th&gt;Base&lt;/th&gt;
&lt;th&gt;umask&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;File&lt;/td&gt;
&lt;td&gt;666&lt;/td&gt;
&lt;td&gt;022&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;644&lt;/strong&gt; (&lt;code&gt;rw-r--r--&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Directory&lt;/td&gt;
&lt;td&gt;777&lt;/td&gt;
&lt;td&gt;022&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;755&lt;/strong&gt; (&lt;code&gt;rwxr-xr-x&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is why a fresh file is &lt;code&gt;644&lt;/code&gt; even though you never ran &lt;code&gt;chmod&lt;/code&gt; — the umask did it for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common umask values worth memorizing
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;umask&lt;/th&gt;
&lt;th&gt;New files&lt;/th&gt;
&lt;th&gt;New dirs&lt;/th&gt;
&lt;th&gt;Use case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;022&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;644&lt;/td&gt;
&lt;td&gt;755&lt;/td&gt;
&lt;td&gt;Default on most distros; world-readable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;027&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;640&lt;/td&gt;
&lt;td&gt;750&lt;/td&gt;
&lt;td&gt;Group-friendly, hidden from "others"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;077&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;600&lt;/td&gt;
&lt;td&gt;700&lt;/td&gt;
&lt;td&gt;Private — only the owner can touch it&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A quick gut check: &lt;strong&gt;umask &lt;code&gt;077&lt;/code&gt; is the one you want for SSH keys, secrets, and anything in a shared box.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  When to reach for which
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Need to fix &lt;strong&gt;this file, now&lt;/strong&gt;? → &lt;code&gt;chmod&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Tired of fixing the &lt;strong&gt;same default&lt;/strong&gt; over and over? → set &lt;code&gt;umask&lt;/code&gt; (in your &lt;code&gt;~/.bashrc&lt;/code&gt;, a systemd unit's &lt;code&gt;UMask=&lt;/code&gt;, or &lt;code&gt;/etc/login.defs&lt;/code&gt; for system-wide)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A trap worth knowing: &lt;code&gt;umask&lt;/code&gt; only ever &lt;em&gt;removes&lt;/em&gt; bits. It can't grant execute on a file the way &lt;code&gt;chmod +x&lt;/code&gt; does — the base mode for files is &lt;code&gt;666&lt;/code&gt;, which has no execute bits to begin with. That's why new scripts always need an explicit &lt;code&gt;chmod +x&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it without doing octal math in your head
&lt;/h2&gt;

&lt;p&gt;If you'd rather not compute &lt;code&gt;666 AND NOT 022&lt;/code&gt; by hand, I keep two small client-side tools bookmarked (everything runs in the browser, nothing is uploaded):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An interactive &lt;a href="https://webutilslab.com/umask-calculator/" rel="noopener noreferrer"&gt;umask calculator&lt;/a&gt; — type a mask, see the resulting file/dir modes instantly.&lt;/li&gt;
&lt;li&gt;A longer write-up: &lt;a href="https://webutilslab.com/guides/umask-vs-chmod/" rel="noopener noreferrer"&gt;umask vs chmod, explained&lt;/a&gt; with a full cheat sheet and FAQ.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; &lt;code&gt;chmod&lt;/code&gt; edits one existing file. &lt;code&gt;umask&lt;/code&gt; is the default filter applied to everything you create next. Fix the present with &lt;code&gt;chmod&lt;/code&gt;; fix the future with &lt;code&gt;umask&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;What umask do you run on your servers? I'm curious how many people switched to &lt;code&gt;027&lt;/code&gt;/&lt;code&gt;077&lt;/code&gt; after a close call.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <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>
