snipt

Ctrl+h for KB shortcuts

Bash

Fix broken packages in Ubuntu and Debian

1
2
3
4
5
6
7
8
dpkg --configure -a
apt-get install -f

# If the problem of a broken package still exist, the solution is to edit the dpkg status file manually.

nano /var/lib/dpkg/status

# Locate the corrupt package, and remove the whole block of information about it and save the file.
https://snipt.net/embed/c909f1463882443c12d770afa20dd0d1/
https://snipt.net/raw/c909f1463882443c12d770afa20dd0d1/
c909f1463882443c12d770afa20dd0d1
bash
Bash
8
2016-09-25T19:10:22
True
False
False
Dec 04, 2013 at 02:34 AM
/api/public/snipt/98414/
fix-broken-packages-in-ubuntu-and-debian
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>dpkg --configure -a </span><span id="L-2"><a name="L-2"></a>apt-get install -f </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c"># If the problem of a broken package still exist, the solution is to edit the dpkg status file manually.</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a>nano /var/lib/dpkg/status </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="c"># Locate the corrupt package, and remove the whole block of information about it and save the file.</span> </span></pre></div> </td></tr></table>
apt, broken, debian, dpkg, fix, packages, status, ubuntu

Bash

save and restore the list of installed packages

1
2
3
4
5
dpkg --get-selections > selections.txt

dpkg --set-selections < selections.txt
dselect update
apt-get dselect-upgrade
https://snipt.net/embed/dd50187add2d7bd25d692862d3929072/
https://snipt.net/raw/dd50187add2d7bd25d692862d3929072/
dd50187add2d7bd25d692862d3929072
bash
Bash
5
2016-09-22T07:28:11
True
False
False
/api/public/snipt/6053/
save-and-restore-the-list-of-installed-packages
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>dpkg --get-selections &gt; selections.txt </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>dpkg --set-selections &lt; selections.txt </span><span id="L-4"><a name="L-4"></a>dselect update </span><span id="L-5"><a name="L-5"></a>apt-get dselect-upgrade </span></pre></div> </td></tr></table>
backup, linux, packages

Bash

not centos packages

1
2
3
# Want to query all those packages installed from 3rd party repositories, not CentOS?

rpm -qa --qf '%{NAME} %{VENDOR}\n' | grep -v CentOS
https://snipt.net/embed/a8c0ee941eaa6052898f8ef40ad79d68/
https://snipt.net/raw/a8c0ee941eaa6052898f8ef40ad79d68/
a8c0ee941eaa6052898f8ef40ad79d68
bash
Bash
3
2016-09-24T08:05:18
True
False
False
/api/public/snipt/5481/
not-centos-packages
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># Want to query all those packages installed from 3rd party repositories, not CentOS?</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>rpm -qa --qf <span class="s1">&#39;%{NAME} %{VENDOR}\n&#39;</span> <span class="p">|</span> grep -v CentOS </span></pre></div> </td></tr></table>
centos, packages

Bash

View the Package Changelog

1
2
3
4
5
6
7
# View the Changelog

# Because CentOS and the upstream vendor have backported security patches, the version numbers can often be misleading when you look for CVE fixes. Checking the changelog of a package is a good way to see if the fix has been implemented. Once again, rpm comes to the rescue.

rpm -q --changelog <packagename> | less

# Using less isn't necessary, but for some packages like the kernel, the changelog can be quite long. Using less helps to make things more readable. 
https://snipt.net/embed/c9e19e153aa715cd60329db257425d0f/
https://snipt.net/raw/c9e19e153aa715cd60329db257425d0f/
c9e19e153aa715cd60329db257425d0f
bash
Bash
7
2016-09-26T15:24:33
True
False
False
/api/public/snipt/5479/
view-the-package-changelog
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># View the Changelog</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c"># Because CentOS and the upstream vendor have backported security patches, the version numbers can often be misleading when you look for CVE fixes. Checking the changelog of a package is a good way to see if the fix has been implemented. Once again, rpm comes to the rescue.</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>rpm -q --changelog &lt;packagename&gt; <span class="p">|</span> less </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="c"># Using less isn&#39;t necessary, but for some packages like the kernel, the changelog can be quite long. Using less helps to make things more readable. </span> </span></pre></div> </td></tr></table>
package, packages, rpm

Bash

Query Package Install Order and Dates

1
2
3
4
5
6
# Query Package Install Order and Dates 
# Useful after an upgrade to find old packages that were not upgraded.

rpm -qa --last >~/RPMS_by_Install_Date

# Review the end of the output file in "less" to find all RPMS older than the install date. Can also grep for specific packages and see when they were installed. 
https://snipt.net/embed/fd6c741397ac9c342ccb09539bd55d5d/
https://snipt.net/raw/fd6c741397ac9c342ccb09539bd55d5d/
fd6c741397ac9c342ccb09539bd55d5d
bash
Bash
6
2016-09-22T09:11:02
True
False
False
/api/public/snipt/5478/
query-package-install-order-and-dates
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># Query Package Install Order and Dates </span> </span><span id="L-2"><a name="L-2"></a><span class="c"># Useful after an upgrade to find old packages that were not upgraded.</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>rpm -qa --last &gt;~/RPMS_by_Install_Date </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c"># Review the end of the output file in &quot;less&quot; to find all RPMS older than the install date. Can also grep for specific packages and see when they were installed. </span> </span></pre></div> </td></tr></table>
packages, query, rpm
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.