<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>checkroot &amp;mdash; Paul Sutton</title>
    <link>https://personaljournal.ca/paulsutton/tag:checkroot</link>
    <description>Personal Blog</description>
    <pubDate>Thu, 14 May 2026 02:40:05 +0000</pubDate>
    <item>
      <title>Bash scripting 9 - check for root</title>
      <link>https://personaljournal.ca/paulsutton/bash-scripting-9-check-for-root</link>
      <description>&lt;![CDATA[Bash scripting 9 - check for root&#xA;&#xA;Some tasks require the user to have root or admin permissions in order for the task to be completed successfully.  There are several ways to do this,  some are detailed on AskUbuntu&#xA;&#xA;if ((${EUID:-0} || &#34;$(id -u)&#34;)); then&#xA;  echo You are not root.&#xA;else&#xA;  echo Hello, root.&#xA;fi&#xA;&#xA;Tags&#xA;&#xA;#Bash,#Bashscripting,#BatchProcessing,#CheckRoot&#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Bash scripting 9 – check for root</p>

<p>Some tasks require the user to have root or admin permissions in order for the task to be completed successfully.  There are several ways to do this,  some are detailed on <a href="https://askubuntu.com/questions/15853/how-can-a-script-check-if-its-being-run-as-root" rel="nofollow">AskUbuntu</a></p>

<pre><code class="language-bash">if ((${EUID:-0} || &#34;$(id -u)&#34;)); then
  echo You are not root.
else
  echo Hello, root.
fi
</code></pre>

<p><strong>Tags</strong></p>

<p><a href="/paulsutton/tag:Bash" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Bash</span></a>,<a href="/paulsutton/tag:Bashscripting" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Bashscripting</span></a>,<a href="/paulsutton/tag:BatchProcessing" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">BatchProcessing</span></a>,<a href="/paulsutton/tag:CheckRoot" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">CheckRoot</span></a></p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/bash-scripting-9-check-for-root</guid>
      <pubDate>Mon, 30 Dec 2024 07:00:00 +0000</pubDate>
    </item>
  </channel>
</rss>