<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>ubuntu &amp;mdash; alan</title>
    <link>https://www.franzoni.eu/alan/tag:ubuntu</link>
    <description>Alan&#39;s musings</description>
    <language>en</language>
    <pubDate>Tue, 17 Nov 2026 00:52:51 +0000</pubDate>
    <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>Ubuntu: faster release upgrade</title>
      <link>https://www.franzoni.eu/alan/ubuntu-faster-release-upgrade</link>
      <description>&lt;![CDATA[It might be high time to update to the latest Ubuntu 14.04.&#xA;&#xA;I think that the upgrade process that is provided by Canonical is slightly underoptimal: if you&#39;re using a&#xA;local mirror which can provide a very fast download of all packages, they&#39;ll usually be disabled during the upgrade process, and an official mirror (possibile one very far away) will be employed.&#xA;&#xA;This can lead to a very slow and painful upgrade process.&#xA;&#xA;The solution is easy.&#xA;&#xA;The following instructions regard moving from 12.04 (precise) to 14.04 (trusty)&#xA;&#xA;Switch your sources&#xA;&#xA;Assuming that your official ubuntu sources are configured from /etc/apt/sources.list just do something like:&#xA;&#xA;sudo sed -i.old -e &#39;s/precise/trusty/g&#39; /etc/apt/sources.list&#xA;&#xA;I&#39;m not considering other sources in /etc/apt/sources.list.d, since they&#39;ll be disabled whatsoever; but if you happen&#xA;to have ubuntu sources there as well, you should repeat the SEDding process for each file.&#xA;&#xA;Update your index&#xA;&#xA;sudo apt-get update&#xA;&#xA;Download updated packages without installing&#xA;&#xA;sudo apt-get dist-upgrade --download-only&#xA;&#xA;Revert to old sources&#xA;&#xA;sudo mv -f /etc/apt/sources.list.old /etc/apt/sources.list&#xA;&#xA;Update index again&#xA;&#xA;sudo apt-get update&#xA;&#xA;Rejoice!&#xA;&#xA;Now you can just follow the upgrade instructions and&#xA;almost nothing will be downloaded during the upgrade, because everything is already on your hard drive.&#xA;&#xA;#MostlyUnixish #ubuntu #linux #upgrade&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>It might be high time to update to the latest <a href="https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes" rel="nofollow">Ubuntu 14.04</a>.</p>

<p>I think that the upgrade process that is provided by Canonical is slightly underoptimal: if you&#39;re using a
local mirror which can provide a very fast download of all packages, they&#39;ll usually be disabled during the upgrade process, and an official mirror (possibile one very far away) will be employed.</p>

<p>This can lead to a very slow and painful upgrade process.</p>

<p>The solution is easy.</p>

<p>The following instructions regard moving from 12.04 (precise) to 14.04 (trusty)</p>

<h2 id="switch-your-sources">Switch your sources</h2>

<p>Assuming that your official ubuntu sources are configured from <code>/etc/apt/sources.list</code> just do something like:</p>

<pre><code>sudo sed -i.old -e &#39;s/precise/trusty/g&#39; /etc/apt/sources.list
</code></pre>

<p>I&#39;m not considering other sources in <code>/etc/apt/sources.list.d</code>, since they&#39;ll be disabled whatsoever; but if you happen
to have ubuntu sources there as well, you should repeat the SEDding process for each file.</p>

<h2 id="update-your-index">Update your index</h2>

<pre><code>sudo apt-get update
</code></pre>

<h2 id="download-updated-packages-without-installing">Download updated packages without installing</h2>

<pre><code>sudo apt-get dist-upgrade --download-only
</code></pre>

<h2 id="revert-to-old-sources">Revert to old sources</h2>

<pre><code>sudo mv -f /etc/apt/sources.list.old /etc/apt/sources.list
</code></pre>

<h2 id="update-index-again">Update index again</h2>

<pre><code>sudo apt-get update
</code></pre>

<h2 id="rejoice">Rejoice!</h2>

<p>Now you can just follow the <a href="https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes#Upgrading_from_Ubuntu_12.04_LTS_or_Ubuntu_13.10" rel="nofollow">upgrade instructions</a> and
almost nothing will be downloaded during the upgrade, because everything is already on your hard drive.</p>

<p><a href="/alan/tag:MostlyUnixish" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">MostlyUnixish</span></a> <a href="/alan/tag:ubuntu" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ubuntu</span></a> <a href="/alan/tag:linux" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">linux</span></a> <a href="/alan/tag:upgrade" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">upgrade</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/ubuntu-faster-release-upgrade</guid>
      <pubDate>Thu, 25 Sep 2014 21:04:00 +0000</pubDate>
    </item>
    <item>
      <title>apt-get update: fixing &#39;package index files are corrupted&#39;</title>
      <link>https://www.franzoni.eu/alan/apt-get-update-fixing-package-index-files-are-corrupted</link>
      <description>&lt;![CDATA[Sometimes when performing your daily apt-get update, you&#39;ll experience messages like&#xA;&#xA;blockquote&#xA;E: The package lists or status file could not be parsed or opened.&#xA;/blockquote&#xA;&#xA;or&#xA;&#xA;blockquote&#xA;The package index files are corrupted&#xA;/blockquote&#xA;&#xA;Such messages usually don&#39;t go away for quite a long time, and may prevent legitimate updates from installing.&#xA;&#xA;This usually happens even more frequently if using a proxy to access apt archives.&#xA;&#xA;While I don&#39;t know what&#39;s the root problem, I&#39;ve got a quick workaround that seems to fix the immediate error:&#xA;&#xA;pre&#xA;sudo -s -H bash -c &#39;apt-get clean &amp;&amp; rm -f /var/lib/apt/lists/ ; rm -f /var/lib/apt/lists/partial/ &amp;&amp; apt-get clean &amp;&amp; apt-get update&#39;&#xA;/pre&#xA;&#xA;#MostlyUnixish #linux #ubuntu #debian #deb #apt&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Sometimes when performing your daily <code>apt-get update</code>, you&#39;ll experience messages like</p>

<blockquote>E: The package lists or status file could not be parsed or opened.
</blockquote>

<p>or</p>

<blockquote>The package index files are corrupted
</blockquote>

<p>Such messages usually don&#39;t go away for quite a long time, and may prevent legitimate updates from installing.</p>

<p>This usually happens even more frequently if using a proxy to access apt archives.</p>

<p>While I don&#39;t know what&#39;s the root problem, I&#39;ve got a quick workaround that seems to fix the immediate error:</p>

<pre>
sudo -s -H bash -c &#39;apt-get clean &amp;&amp; rm -f /var/lib/apt/lists/* ; rm -f /var/lib/apt/lists/partial/* &amp;&amp; apt-get clean &amp;&amp; apt-get update&#39;
</pre>

<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:ubuntu" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ubuntu</span></a> <a href="/alan/tag:debian" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">debian</span></a> <a href="/alan/tag:deb" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">deb</span></a> <a href="/alan/tag:apt" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">apt</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/apt-get-update-fixing-package-index-files-are-corrupted</guid>
      <pubDate>Wed, 06 Mar 2013 21:45:00 +0000</pubDate>
    </item>
    <item>
      <title>Purging outdated kernels on systems with unattended-upgrades</title>
      <link>https://www.franzoni.eu/alan/purging-outdated-kernels-on-systems-with-unattended-upgrades</link>
      <description>&lt;![CDATA[Whenever I install a production system/server I tend to enable full automatic updating, because&#xA;it&#39;s usually better that something breaks because of a failed update rather than leaving a production machine unpatched; and if you pick a rather stable distribution (Centos or Ubuntu LTS are good examples) chances that you&#39;ll end up with a broken system are fairly low.&#xA;&#xA;Btw let&#39;s get back to the point: in such cases you may end up with a disk which was filled up with obsolete kernels. The following snippets allows you to get all outdated kernels which are not in use, so you can automagically pipe its output to an  apt-get remove -y in a cron job.&#xA;&#xA;That may sound trivial, but what happens if you&#39;re not careful (e.g. if you try deleting all kernels but the latest) is that you might try removing the currently running kernel - and it&#39;s pretty bad if that happens in an unattended cron job.&#xA;&#xA;!/usr/bin/env python&#xA;&#xA;print all installed kernel/headers/etc BUT the current and the latest;&#xA;suitable to be used with apt-get remove.&#xA;requires aptitude to be installed. Works on Ubuntu and probably Debian&#xA;&#xA;from subprocess import checkoutput&#xA;import re&#xA;&#xA;def runcmd(s):&#xA;    return checkoutput(s.split())&#xA;&#xA;should work for anything until kernel 3.100&#xA;kernelversionpattern = re.compile(&#34;[23]\.\d{1,2}\.\d{1,2}-\d{1,3}&#34;)&#xA;def getkernelversion(kernelstring):&#xA;    return kernelversionpattern.search(kernelstring).group(0)&#xA;&#xA;def getprovidingpackages(pkg):&#xA;    return filter(lambda x: x != &#34;&#34;,&#xA;        map(str.strip,&#xA;            runcmd(&#39;aptitude search ~i~P%s -F%%p&#39; % pkg).split(&#34;\n&#34;)&#xA;            )&#xA;        )&#xA;&#xA;def getnonmatchingpackages(packagelist, excluding):&#xA;    return [k for k in packagelist if not getkernelversion(k) in&#xA;        excluding]&#xA;&#xA;allkernels = getprovidingpackages(&#34;linux-image&#34;)&#xA;allkernels.sort() # lexicographical&#xA;&#xA;kernelversions = map(getkernelversion, allkernels)&#xA;latestversion = kernelversions[-1]&#xA;currentversion = getkernelversion(runcmd(&#34;uname -r&#34;))&#xA;&#xA;kernelstoremove = getnonmatchingpackages(allkernels, (currentversion,&#xA;    latestversion))&#xA;&#xA;implheaders = getprovidingpackages(&#34;linux-headers&#34;)&#xA;&#xA;headerstoremove = getnonmatchingpackages(implheaders, (currentversion,&#xA;    latestversion))&#xA;&#xA;This seems to be needed in Ubuntu   = 13.04&#xA;baseheaderstoremove = [header.replace(&#34;-generic&#34;, &#34;&#34;) for header in headerstoremove]&#xA;headerstoremove += baseheaderstoremove&#xA;&#xA;print &#34; &#34;.join(kernelstoremove + headerstoremove)&#xA;&#xA;Suggested use in a cron job, of course, is just:&#xA;&#xA;apt-get remove --purge -y ubuntugetobsoletekernelandheaderspkgs.py&#xA;&#xA;WARNING: recent changes to the way Ubuntu marks dependencies and provided names for kernel headers require that you uncomment a couple of lines in the script towards the end; just remove the \# at the beginning of the lines 46 and 47.&#xA;&#xA;UPDATE: in recent Ubuntu versions, just invoking apt-get autoremove --purge will do the trick. Such command will remove all automatically installed packages that are no longer required in the running system. It can remove other packages beyond outdated kernels, by the way.&#xA;&#xA;#MostlyUnixish #linux #ubuntu #debian #update #maintenance&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Whenever I install a production system/server I tend to enable full automatic updating, because
it&#39;s usually better that something breaks because of a failed update rather than leaving a production machine unpatched; and if you pick a rather stable distribution (Centos or Ubuntu LTS are good examples) chances that you&#39;ll end up with a broken system are fairly low.</p>

<p>Btw let&#39;s get back to the point: in such cases you may end up with a disk which was filled up with obsolete kernels. The following snippets allows you to get all outdated kernels which are not in use, so you can automagically pipe its output to an <code>apt-get remove -y</code> in a cron job.</p>

<p>That may sound trivial, but what happens if you&#39;re not careful (e.g. if you try deleting all kernels but the latest) is that you might try removing the currently running kernel – and it&#39;s pretty bad if that happens in an unattended cron job.</p>

<pre><code class="language-python">#!/usr/bin/env python

# print all installed kernel/headers/etc BUT the current and the latest;
# suitable to be used with apt-get remove.
# requires aptitude to be installed. Works on Ubuntu and probably Debian

from subprocess import check_output
import re

def runcmd(s):
    return check_output(s.split())

# should work for anything until kernel 3.100
kernel_version_pattern = re.compile(&#34;[23]\.\d{1,2}\.\d{1,2}-\d{1,3}&#34;)
def get_kernel_version(kernelstring):
    return kernel_version_pattern.search(kernelstring).group(0)

def get_providing_packages(pkg):
    return filter(lambda x: x != &#34;&#34;,
        map(str.strip,
            runcmd(&#39;aptitude search ~i~P%s -F%%p&#39; % pkg).split(&#34;\n&#34;)
            )
        )

def get_nonmatching_packages(package_list, excluding):
    return [k for k in package_list if not get_kernel_version(k) in
        excluding]

all_kernels = get_providing_packages(&#34;linux-image&#34;)
all_kernels.sort() # lexicographical

kernel_versions = map(get_kernel_version, all_kernels)
latest_version = kernel_versions[-1]
current_version = get_kernel_version(runcmd(&#34;uname -r&#34;))

kernels_to_remove = get_nonmatching_packages(all_kernels, (current_version,
    latest_version))

impl_headers = get_providing_packages(&#34;linux-headers&#34;)

headers_to_remove = get_nonmatching_packages(impl_headers, (current_version,
    latest_version))

# This seems to be needed in Ubuntu &gt;= 13.04
#base_headers_to_remove = [header.replace(&#34;-generic&#34;, &#34;&#34;) for header in headers_to_remove]
#headers_to_remove += base_headers_to_remove

print &#34; &#34;.join(kernels_to_remove + headers_to_remove)
</code></pre>

<p>Suggested use in a cron job, of course, is just:</p>

<pre><code>apt-get remove --purge -y `ubuntu_get_obsolete_kernel_and_headers_pkgs.py`
</code></pre>

<p><strong>WARNING</strong>: recent changes to the way Ubuntu marks dependencies and provided names for kernel headers require that you uncomment a couple of lines in the script towards the end; just remove the # at the beginning of the lines 46 and 47.</p>

<p><strong>UPDATE</strong>: in recent Ubuntu versions, just invoking <code>apt-get autoremove --purge</code> will do the trick. Such command will remove all automatically installed packages that are no longer required in the running system. It can remove other packages beyond outdated kernels, by the way.</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:ubuntu" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">ubuntu</span></a> <a href="/alan/tag:debian" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">debian</span></a> <a href="/alan/tag:update" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">update</span></a> <a href="/alan/tag:maintenance" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">maintenance</span></a></p>
]]></content:encoded>
      <guid>https://www.franzoni.eu/alan/purging-outdated-kernels-on-systems-with-unattended-upgrades</guid>
      <pubDate>Mon, 25 Jun 2012 20:33:00 +0000</pubDate>
    </item>
  </channel>
</rss>