<?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: Evan Lee</title>
    <description>The latest articles on DEV Community by Evan Lee (@evanlee).</description>
    <link>https://dev.to/evanlee</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%2F3884801%2F3fb3f1f2-d693-4931-8f4e-7c2c1c10b7e1.png</url>
      <title>DEV Community: Evan Lee</title>
      <link>https://dev.to/evanlee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/evanlee"/>
    <language>en</language>
    <item>
      <title>Some systemctl Tricks I Wish I Knew Earlier</title>
      <dc:creator>Evan Lee</dc:creator>
      <pubDate>Fri, 17 Apr 2026 15:54:30 +0000</pubDate>
      <link>https://dev.to/evanlee/some-systemctl-tricks-i-wish-i-knew-earlier-3nng</link>
      <guid>https://dev.to/evanlee/some-systemctl-tricks-i-wish-i-knew-earlier-3nng</guid>
      <description>&lt;p&gt;Some Less Obvious systemctl Tricks I Only Learned After Using It for a While&lt;/p&gt;

&lt;p&gt;I’ve been using systemd for a while now, mostly just the usual &lt;code&gt;start&lt;/code&gt;, &lt;code&gt;stop&lt;/code&gt;, &lt;code&gt;status&lt;/code&gt;, nothing fancy.&lt;/p&gt;

&lt;p&gt;But after running into a few annoying issues, I realized there are a bunch of &lt;code&gt;systemctl&lt;/code&gt; things that aren’t obvious at first but end up being pretty useful.&lt;/p&gt;

&lt;p&gt;Just writing a few of them down so I don’t forget.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. &lt;code&gt;systemctl restart&lt;/code&gt; is not always what you want
&lt;/h3&gt;

&lt;p&gt;I used to blindly run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl restart myservice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But that actually does a full stop + start. If your service supports reload, sometimes this is better:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl reload myservice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or even:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl reload-or-restart myservice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This one is nice because it tries reload first, and only restarts if reload isn’t supported.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Checking logs without guessing the journal
&lt;/h3&gt;

&lt;p&gt;Instead of manually digging into logs, you can just do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;journalctl &lt;span class="nt"&gt;-u&lt;/span&gt; myservice &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It basically acts like &lt;code&gt;tail -f&lt;/code&gt; but scoped to the service.&lt;/p&gt;

&lt;p&gt;I didn’t use this at first and kept checking random log files. This is much cleaner.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Why your service “fails instantly”
&lt;/h3&gt;

&lt;p&gt;This one confused me for a while.&lt;/p&gt;

&lt;p&gt;If your service runs something quick (like a script that exits), systemd might mark it as failed even though nothing is actually wrong.&lt;/p&gt;

&lt;p&gt;The fix is usually in the service file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight systemd"&gt;&lt;code&gt;&lt;span class="nt"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;oneshot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or adding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight systemd"&gt;&lt;code&gt;&lt;span class="nt"&gt;RemainAfterExit&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;yes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Otherwise systemd expects a long-running process.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. &lt;code&gt;systemctl daemon-reexec&lt;/code&gt; vs &lt;code&gt;daemon-reload&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;I always used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl daemon-reload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which reloads unit files.&lt;/p&gt;

&lt;p&gt;But there’s also:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl daemon-reexec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This one actually restarts systemd itself (without rebooting the system).&lt;/p&gt;

&lt;p&gt;I don’t use it often, but it’s good to know when systemd itself gets into a weird state.&lt;/p&gt;




&lt;h3&gt;
  
  
  5. Masking a service (stronger than disable)
&lt;/h3&gt;

&lt;p&gt;I used to think &lt;code&gt;disable&lt;/code&gt; was enough:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl disable myservice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it can still be started manually or by dependencies.&lt;/p&gt;

&lt;p&gt;If you really want to prevent it from ever running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl mask myservice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This basically links it to &lt;code&gt;/dev/null&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Took me a while to realize this existed.&lt;/p&gt;




&lt;h3&gt;
  
  
  6. Seeing why something started
&lt;/h3&gt;

&lt;p&gt;Sometimes a service starts and you have no idea why.&lt;/p&gt;

&lt;p&gt;This helps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl list-dependencies &lt;span class="nt"&gt;--reverse&lt;/span&gt; myservice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It shows what depends on it, which usually explains why it got pulled in.&lt;/p&gt;




&lt;h3&gt;
  
  
  Final note
&lt;/h3&gt;

&lt;p&gt;None of these are super advanced, but they’re the kind of things I wish I knew earlier.&lt;/p&gt;

&lt;p&gt;Most of my interaction with systemd is still just start/stop, but once you run into edge cases, these commands start to matter a lot more.&lt;/p&gt;

</description>
      <category>systemctl</category>
      <category>linux</category>
      <category>archlinux</category>
      <category>systems</category>
    </item>
  </channel>
</rss>
