<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>ancientwisdom &amp;mdash; alan</title>
    <link>https://www.franzoni.eu/alan/tag:ancientwisdom</link>
    <description>Alan&#39;s musings</description>
    <language>en</language>
    <pubDate>Tue, 17 Nov 2026 00:40:57 +0000</pubDate>
    <item>
      <title>chmod and the capital X</title>
      <link>https://www.franzoni.eu/alan/chmod-and-the-capital-x</link>
      <description>&lt;![CDATA[This is one very, very, very interesting piece of ancient wisdom.&#xA;&#xA;Suppose you need to change permissions for some directories. Maybe the permissions are too strict, e.g. something like 700 for directories and 600 for files, and you need to give access to some other group and not just the owner.&#xA;&#xA;As you know, execute permission on directories is required for traversal. So you might think doing something like:&#xA;&#xA;chmod -R g+rx /var/somedirectory&#xA;&#xA;This would probably work, but would leave you in a sad state: you&#39;ll get the executable bit set on files that are not supposed to be executable at all, which may be just annoying but may get risky as well.&#xA;&#xA;A great alternative is:&#xA;&#xA;chmod -R g+rX /var/somedirectory&#xA;&#xA;the capital X means: set the executable bit only if the target a) is a directory b) has already at least one executable bit set for any one of user, group, others.&#xA;&#xA;There&#39;s another alternative that may be appealing in some situations, at least when you want to give the group the same permissions as the owner:&#xA;&#xA;chmod -R g=u /var/somedirectory&#xA;&#xA;This will give any file the group permissions identical to the user&#39;s permission.&#xA;&#xA;#MostlyUnixish #linux #ancientwisdom #chmod&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>This is one very, very, very interesting piece of ancient wisdom.</p>

<p>Suppose you need to change permissions for some directories. Maybe the permissions are too strict, e.g. something like 700 for directories and 600 for files, and you need to give access to some other group and not just the owner.</p>

<p>As you know, execute permission on directories is required for traversal. So you might think doing something like:</p>

<pre><code class="language-bash">chmod -R g+rx /var/somedirectory
</code></pre>

<p>This would probably work, but would leave you in a sad state: you&#39;ll get the executable bit set on files that are not supposed to be executable at all, which may be just annoying but may get risky as well.</p>

<p>A great alternative is:</p>

<pre><code class="language-bash">chmod -R g+rX /var/somedirectory
</code></pre>

<p>the capital X means: <em>set the executable bit only if the target a) is a directory b) has already at least one executable bit set for any one of user, group, others</em>.</p>

<p>There&#39;s another alternative that may be appealing in some situations, at least when you want to give the group the same permissions as the owner:</p>

<pre><code class="language-bash">chmod -R g=u /var/somedirectory
</code></pre>

<p>This will give any file the group permissions identical to the user&#39;s permission.</p>

<p><a href="/alan/tag:MostlyUnixish" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">MostlyUnixish</span></a> <a href="/alan/tag:linux" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">linux</span></a> <a href="/alan/tag:ancientwisdom" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ancientwisdom</span></a> <a href="/alan/tag:chmod" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">chmod</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/chmod-and-the-capital-x</guid>
      <pubDate>Tue, 27 Jan 2015 22:31:00 +0000</pubDate>
    </item>
    <item>
      <title>Unfreezing your desktop: when Compiz goes wrong</title>
      <link>https://www.franzoni.eu/alan/unfreezing-your-desktop-when-compiz-goes-wrong</link>
      <description>&lt;![CDATA[A desktop freeze is something that&#39;s not so rare nowadays - that&#39;s not good, but we shouldn&#39;t get desperate about that.&#xA;&#xA;I like Compiz with Unity Desktop on my Ubuntu Trusty very much; I feel it&#39;s a step forward compared to traditional desktops. The only major nuisance I had on the previous versions was the inability to disable the global menu (which I like by itself, but I don&#39;t like the global menu disappearing when the mouse is not over it), but you can now disable it and have the menu on the window - even though you can&#39;t still enable an always-visible behaviour.&#xA;&#xA;The problem is: compiz sometimes gets buggy. Running a different window manager, like metacity and/or xcompmgr just doesn&#39;t seem good, you can experience other issues and you&#39;re using the stack in a way it wasn&#39;t designed for. I don&#39;t like that approach.&#xA;&#xA;So, what can you do when your desktop freezes? The symptoms are usually very clear: you can move your mouse, but you can&#39;t click nor type anything.&#xA;&#xA;You don&#39;t need to reboot nor to restart X. You can fix this without losing your work.&#xA;&#xA;Get a raw tty&#xA;&#xA;Press Ctrl+Alt+F1 and get to a raw linux console, and login with your credentials. Make sure you use the same user you&#39;re logged into X with.&#xA;&#xA;Find and kill your stuck process&#xA;&#xA;pgrep compiz&#xA;&#xA;This will print the PID of our stuck window manager.&#xA;&#xA;Let&#39;s kill it&#xA;&#xA;pkill compiz&#xA;&#xA;This won&#39;t usually be enough because the process is really stuck: if you repeat the pgrep command above, you&#39;ll find it still running - i.e. pgrep will return the very same PID as above.&#xA;&#xA;So let&#39;s kill it, really this time!&#xA;&#xA;pkill -9 compiz&#xA;&#xA;Then wait some 15-20 seconds.&#xA;&#xA;Now, if you repeat the pgrep , you&#39;ll either see a) no result or b) a different PID.&#xA;&#xA;If you see a different PID, it&#39;s Ubuntu that noticed the crashed process and relaunched it; press Ctrl+Alt+F7, and you should just get back a working desktop!&#xA;&#xA;Relaunching&#xA;&#xA;If you see nothing with pgrep, you&#39;ll need to relaunch Compiz manually.&#xA;&#xA;You cannot simply relaunch compiz on the console, because it must connect to X: the proper way to do it is:&#xA;&#xA;DISPLAY=:0 compiz&#xA;&#xA;Now switch back to your X instance with Ctrl+Alt+F7 and enjoy!&#xA;&#xA;#MostlyUnixish #linux #ancientwisdom #community #ubuntu #compiz&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>A desktop freeze is something that&#39;s not so rare nowadays – that&#39;s not good, but we shouldn&#39;t get desperate about that.</p>

<p>I like <a href="http://www.compiz.org" rel="nofollow">Compiz</a> with <a href="https://unity.ubuntu.com/" rel="nofollow">Unity Desktop</a> on my <a href="https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes" rel="nofollow">Ubuntu Trusty</a> very much; <strong>I feel it&#39;s a step forward compared to traditional desktops</strong>. The only major nuisance I had on the previous versions was the inability to disable the global menu (which I like by itself, but I don&#39;t like the global menu disappearing when the mouse is not over it), but you can now disable it and have the menu on the window – even though you can&#39;t still enable an always-visible behaviour.</p>

<p>The problem is: compiz sometimes gets buggy. Running a different window manager, like <a href="https://help.ubuntu.com/community/Metacity" rel="nofollow">metacity</a> and/or <a href="http://cgit.freedesktop.org/xorg/app/xcompmgr/" rel="nofollow">xcompmgr</a> just doesn&#39;t seem good, you can experience other issues and you&#39;re using the stack in a way it wasn&#39;t designed for. I don&#39;t like that approach.</p>

<p>So, what can you do when your desktop freezes? The symptoms are usually very clear: you can move your mouse, but you can&#39;t click nor type anything.</p>

<p><strong>You don&#39;t need to reboot nor to restart X.</strong> You can fix this without losing your work.</p>

<h2 id="get-a-raw-tty">Get a raw tty</h2>

<p>Press <em>Ctrl+Alt+F1</em> and get to a raw linux console, and login with your credentials. Make sure you use the same user you&#39;re logged into X with.</p>

<h2 id="find-and-kill-your-stuck-process">Find and kill your stuck process</h2>

<pre><code>pgrep compiz
</code></pre>

<p>This will print the PID of our stuck window manager.</p>

<p>Let&#39;s kill it</p>

<pre><code>pkill compiz
</code></pre>

<p>This <strong>won&#39;t usually be enough</strong> because the process is really stuck: if you repeat the <em>pgrep</em> command above, you&#39;ll find it still running – i.e. pgrep will return the very same PID as above.</p>

<p>So let&#39;s kill it, really this time!</p>

<pre><code>pkill -9 compiz
</code></pre>

<p>Then wait some 15-20 seconds.</p>

<p>Now, if you repeat the <em>pgrep</em> , you&#39;ll either see a) no result or b) a different PID.</p>

<p>If you see a different PID, it&#39;s Ubuntu that noticed the crashed process and relaunched it; press <em>Ctrl+Alt+F7</em>, and you should just get back a working desktop!</p>

<h2 id="relaunching">Relaunching</h2>

<p>If you see nothing with pgrep, you&#39;ll need to relaunch Compiz manually.</p>

<p>You cannot simply relaunch compiz on the console, because it must connect to X: the proper way to do it is:</p>

<pre><code>DISPLAY=:0 compiz
</code></pre>

<p>Now switch back to your X instance with <em>Ctrl+Alt+F7</em> and enjoy!</p>

<p><a href="/alan/tag:MostlyUnixish" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">MostlyUnixish</span></a> <a href="/alan/tag:linux" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">linux</span></a> <a href="/alan/tag:ancientwisdom" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ancientwisdom</span></a> <a href="/alan/tag:community" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">community</span></a> <a href="/alan/tag:ubuntu" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ubuntu</span></a> <a href="/alan/tag:compiz" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">compiz</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/unfreezing-your-desktop-when-compiz-goes-wrong</guid>
      <pubDate>Fri, 12 Dec 2014 22:28:00 +0000</pubDate>
    </item>
    <item>
      <title>Don&#39;t give a shell to system users - use su</title>
      <link>https://www.franzoni.eu/alan/dont-give-a-shell-to-system-users-use-su</link>
      <description>&lt;![CDATA[I seem very ancientwisdom-oriented these days.&#xA;&#xA;Sometimes you&#39;ve got a system user on your linux server that&#39;s used to run a specific service; it&#39;s a good practice to employ those users to achieve privilege separation, since it limits the impact of many security breaches. It&#39;s security 101, really.&#xA;&#xA;If you&#39;ve got a system user, most probably its shell would be /bin/false or /bin/nologin. Again, this is a good practice, since it would be harder for an attacker to gain shell access to your machine through that user.&#xA;&#xA;But I find that many people just change such shell, because sometimes they need to customize the environment for a user, and if you try doing something like&#xA;&#xA;su - systemuser&#xA;&#xA;you&#39;ll find yourself just back to your original shell, because su tries to invoke the shell which is set for the target user, and sudo doesn&#39;t generally help here, because its --shell option doesn&#39;t start a proper login shell for that user (most of the environment is that of the calling user).&#xA;&#xA;Very well, gentlemen: this is a wrongdoing and a potential security hole. You should never enable a shell for your system users. Instead, you should leverage an option of su:&#xA;&#xA;su - systemuser --shell /bin/bash&#xA;&#xA;That lets you choose your favourite shell on a per-launch basis.&#xA;&#xA;#MostlyUnixish #linux #ancientwisdom #su #security&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>I seem very ancientwisdom-oriented these days.</p>

<p>Sometimes you&#39;ve got a system user on your linux server that&#39;s used to run a specific service; it&#39;s a good practice to employ those users to achieve <a href="http://en.wikipedia.org/wiki/Privilege_separation" rel="nofollow">privilege separation</a>, since it limits the impact of many security breaches. It&#39;s security 101, really.</p>

<p>If you&#39;ve got a system user, most probably its shell would be <code>/bin/false</code> or <code>/bin/nologin</code>. Again, this is a good practice, since it would be harder for an attacker to gain shell access to your machine through that user.</p>

<p>But I find that many people just <strong>change</strong> such shell, because sometimes they need to customize the environment for a user, and if you try doing something like</p>

<pre><code>su - systemuser
</code></pre>

<p>you&#39;ll find yourself just back to your original shell, because <strong>su</strong> tries to invoke the shell which is set for the target user, and <code>sudo</code> doesn&#39;t generally help here, because its <code>--shell</code> option doesn&#39;t start a proper login shell for that user (most of the environment is that of the calling user).</p>

<p>Very well, gentlemen: <strong>this is a wrongdoing and a potential security hole</strong>. You should <strong>never</strong> enable a shell for your system users. Instead, you should leverage an option of <strong>su</strong>:</p>

<pre><code>su - systemuser --shell /bin/bash
</code></pre>

<p>That lets you choose your favourite shell on a per-launch basis.</p>

<p><a href="/alan/tag:MostlyUnixish" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">MostlyUnixish</span></a> <a href="/alan/tag:linux" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">linux</span></a> <a href="/alan/tag:ancientwisdom" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ancientwisdom</span></a> <a href="/alan/tag:su" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">su</span></a> <a href="/alan/tag:security" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">security</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/dont-give-a-shell-to-system-users-use-su</guid>
      <pubDate>Thu, 11 Dec 2014 22:25:00 +0000</pubDate>
    </item>
    <item>
      <title>SSH hostnames configuration and shortcuts</title>
      <link>https://www.franzoni.eu/alan/ssh-hostnames-configuration-and-shortcuts</link>
      <description>&lt;![CDATA[This is another old trick, but I like to tell the world about such amenities.&#xA;&#xA;I often find people writing command lines such as:&#xA;&#xA;ssh arcane-system-user@someextremelylong.andimpossibiletotype.anderrorprone.hostname.com&#xA;&#xA;or, worse&#xA;&#xA;ssh idliketorememberwhichuser@10.20.30.40&#xA;&#xA;or maybe it was&#xA;&#xA;ssh someuserimashamedof@1.2.3.4&#xA;&#xA;yes, sometimes ssh is simply tedious.&#xA;&#xA;But you can do better. In fact, you can do much better.&#xA;&#xA;your ~/.ssh/config or /etc/ssh/ssh\_config can contain Host configuration sections; I have already blogged about such directives when I told the world about stopping key verification compliants - they&#39;re very flexible, indeed.&#xA;&#xA;Consider adding Host directives in your configuration for your most used services:&#xA;&#xA;Host myniceserver&#xA;    Hostname myniceserver.mylove.com&#xA;    Port 12345&#xA;    User teddybear&#xA;&#xA;And then you can just&#xA;&#xA;ssh myniceserver&#xA;&#xA;You can override most options on a per-server basis and/or select a certain private key for connections.&#xA;&#xA;#MostlyUnixish #linux #ssh #ancientwisdom&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>This is another old trick, but I like to tell the world about such amenities.</p>

<p>I often find people writing command lines such as:</p>

<pre><code>ssh arcane-system-user@someextremelylong.andimpossibiletotype.anderrorprone.hostname.com
</code></pre>

<p>or, worse</p>

<pre><code>ssh idliketorememberwhichuser@10.20.30.40
</code></pre>

<p>or maybe it was</p>

<pre><code>ssh someuserimashamedof@1.2.3.4
</code></pre>

<p>yes, sometimes ssh is simply tedious.</p>

<p>But you can do better. In fact, you can do <strong>much</strong> better.</p>

<p>your <em>~/.ssh/config</em> or <em>/etc/ssh/ssh_config</em> can contain <strong>Host</strong> configuration sections; I have already blogged about such directives when I told the world about stopping <a href="/alan/ssh-client-stopping-key-verification-complaints-inside-your-own-private-network" rel="nofollow">key verification compliants</a> – they&#39;re very flexible, indeed.</p>

<p>Consider adding <strong>Host</strong> directives in your configuration for your most used services:</p>

<pre><code>Host myniceserver
    Hostname myniceserver.mylove.com
    Port 12345
    User teddybear
</code></pre>

<p>And then you can just</p>

<pre><code>ssh myniceserver
</code></pre>

<p>You can override most options on a per-server basis and/or select a certain private key for connections.</p>

<p><a href="/alan/tag:MostlyUnixish" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">MostlyUnixish</span></a> <a href="/alan/tag:linux" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">linux</span></a> <a href="/alan/tag:ssh" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ssh</span></a> <a href="/alan/tag:ancientwisdom" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ancientwisdom</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/ssh-hostnames-configuration-and-shortcuts</guid>
      <pubDate>Wed, 10 Dec 2014 22:24:00 +0000</pubDate>
    </item>
  </channel>
</rss>