<?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: Conor Sinclair</title>
    <description>The latest articles on DEV Community by Conor Sinclair (@csinclair).</description>
    <link>https://dev.to/csinclair</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%2F181464%2F8aa6d2c1-6857-4065-93dd-314b05fca40a.jpeg</url>
      <title>DEV Community: Conor Sinclair</title>
      <link>https://dev.to/csinclair</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/csinclair"/>
    <language>en</language>
    <item>
      <title>Find and stop systemd services</title>
      <dc:creator>Conor Sinclair</dc:creator>
      <pubDate>Fri, 28 Jan 2022 10:21:35 +0000</pubDate>
      <link>https://dev.to/csinclair/find-and-stop-systemd-services-b7k</link>
      <guid>https://dev.to/csinclair/find-and-stop-systemd-services-b7k</guid>
      <description>&lt;p&gt;I use Caddy server on occasion for work. Its awesome. Well worth looking into, and I’m sure I’ll write a more in depth piece on its finer points sometime, but for now its the object of this particular narrative, not the focus. &lt;/p&gt;

&lt;p&gt;So I kept finding that when I went to start Caddy with a custom configuration, it would fail due to the ports required for Caddy to run being already in use. &lt;/p&gt;

&lt;p&gt;A bit of delving using our handy CLI toolbox identifies which process is hogging the port in question (2019)&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;sudo &lt;/span&gt;netstat &lt;span class="nt"&gt;-nlp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; :2019
&lt;span class="c"&gt;#=&amp;gt;  tcp  0  0  127.0.0.1:2019  0.0.0.0:*  LISTEN  18648/caddy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So Caddy is already running... &lt;/p&gt;

&lt;p&gt;This is strange as I never started that process.&lt;/p&gt;

&lt;p&gt;For a while I took the amateur’s way out, and just killed the running Caddy process, before starting my own.&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;sudo &lt;/span&gt;pkill caddy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But c’mon, we all know we can do much better than that.&lt;/p&gt;

&lt;p&gt;The next clue as to why this keeps happening is the fact that this ghost Caddy process will be present from every time I start my machine. In Linux, &lt;code&gt;systemd&lt;/code&gt; is responsible for starting processes at given times - like after boot. It does this via “services”. If a service is enabled then it will fire up on boot of the OS.&lt;br&gt;
We can find all the currently enabled services with a &lt;code&gt;systemd list-unit-files --state=enabled&lt;/code&gt; command, but this will return us a bit of a beast of a list. So let’s pipe it to our old friend &lt;code&gt;fzf&lt;/code&gt; (&lt;code&gt;grep&lt;/code&gt; would be a fine choice as well).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemd list-unit-files &lt;span class="nt"&gt;--state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;enabled | fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I start typing Caddy and there it is: “caddy.service enabled enabled”. So all we need to do is &lt;code&gt;systemd disable&lt;/code&gt; it and we’ll stop the service from being started on boot!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemd disable caddy.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And there we have it. Another minor annoyance solved, and literally seconds every day saved! Incredible!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>systemd</category>
    </item>
    <item>
      <title>Copy public IP address to system clipboard </title>
      <dc:creator>Conor Sinclair</dc:creator>
      <pubDate>Thu, 13 Jan 2022 18:09:04 +0000</pubDate>
      <link>https://dev.to/csinclair/copy-public-ip-address-to-system-clipboard-4ejd</link>
      <guid>https://dev.to/csinclair/copy-public-ip-address-to-system-clipboard-4ejd</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl ifconfig.me | xclip &lt;span class="nt"&gt;-sel&lt;/span&gt; clipboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
      <category>cli</category>
      <category>networking</category>
    </item>
    <item>
      <title>Want to unstage something from Git? </title>
      <dc:creator>Conor Sinclair</dc:creator>
      <pubDate>Thu, 13 Jan 2022 17:56:07 +0000</pubDate>
      <link>https://dev.to/csinclair/want-to-unstage-something-from-git-4h1j</link>
      <guid>https://dev.to/csinclair/want-to-unstage-something-from-git-4h1j</guid>
      <description>&lt;p&gt;No problem, just do a&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git restore &lt;span class="nt"&gt;--stage&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;path]

&lt;span class="c"&gt;# Or even easier &lt;/span&gt;

git reset &lt;span class="o"&gt;[&lt;/span&gt;path]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One less thing you need a GUI for! &lt;/p&gt;

</description>
      <category>git</category>
      <category>terminal</category>
    </item>
  </channel>
</rss>
