snipt

Ctrl+h for KB shortcuts

Bash

Ubuntu purge old Kernels - free up /boot

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
https://snipt.net/embed/e74c670f9bfe59a05756f9978f9911b0/
/raw/e74c670f9bfe59a05756f9978f9911b0/
e74c670f9bfe59a05756f9978f9911b0
bash
Bash
1
2019-07-22T23:05:36
True
False
False
/api/public/snipt/55285/
ubuntu-purge-old-kernels-free-up-boot
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>sudo apt-get purge <span class="k">$(</span>dpkg -l linux-<span class="o">{</span>image,headers<span class="o">}</span>-<span class="s2">&quot;[0-9]*&quot;</span> <span class="p">|</span> awk <span class="s1">&#39;/ii/{print $2}&#39;</span> <span class="p">|</span> grep -ve <span class="s2">&quot;</span><span class="k">$(</span>uname -r <span class="p">|</span> sed -r <span class="s1">&#39;s/-[a-z]+//&#39;</span><span class="k">)</span><span class="s2">&quot;</span><span class="k">)</span> </span></pre></div> </td></tr></table>