Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Bash

Get package version from deb file

debFile="/path/to/deb/file"
dpkg -I "$debFile"  | grep -oP '(?<=Version: ).*'
https://snipt.net/embed/0bf8d894f6ead618ac4cf860825e6a34/
https://snipt.net/raw/0bf8d894f6ead618ac4cf860825e6a34/
0bf8d894f6ead618ac4cf860825e6a34
bash
Bash
2
2016-12-10T16:02:01
True
False
False
Oct 06, 2015 at 08:16 AM
/api/public/snipt/141521/
get-package-version-from-deb-file
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nv">debFile</span><span class="o">=</span><span class="s2">&quot;/path/to/deb/file&quot;</span> </span><span id="L-2"><a name="L-2"></a>dpkg -I <span class="s2">&quot;</span><span class="nv">$debFile</span><span class="s2">&quot;</span> <span class="p">|</span> grep -oP <span class="s1">&#39;(?&lt;=Version: ).*&#39;</span> </span></pre></div> </td></tr></table>
bash, deb, linux, package, ubuntu

Bash

get installed version of package

packageName="dreampie"
apt-cache policy "$packageName" | grep -oP "(?<=Installed: ).*$" || { echo "Not installed"; }
https://snipt.net/embed/abe43dda393d51df967f0de029e78284/
https://snipt.net/raw/abe43dda393d51df967f0de029e78284/
abe43dda393d51df967f0de029e78284
bash
Bash
3
2016-12-06T03:35:14
True
False
False
/api/public/snipt/141322/
get-installed-version-of-package
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nv">packageName</span><span class="o">=</span><span class="s2">&quot;dreampie&quot;</span> </span><span id="L-2"><a name="L-2"></a>apt-cache policy <span class="s2">&quot;</span><span class="nv">$packageName</span><span class="s2">&quot;</span> <span class="p">|</span> grep -oP <span class="s2">&quot;(?&lt;=Installed: ).*</span>$<span class="s2">&quot;</span> <span class="o">||</span> <span class="o">{</span> <span class="nb">echo</span> <span class="s2">&quot;Not installed&quot;</span><span class="p">;</span> <span class="o">}</span> </span></pre></div> </td></tr></table>
apt, linux, package

Text only

Rollback to previous package version after bad upgrade with Ubuntu 8.04LTS and APT

1
2
3
4
5
This will show all the versions of the package in the cache
apt-cache show [package name] | fgrep Version:

This will install an older version of the package
apt-get install [package name]=[version]
https://snipt.net/embed/c1f36e0159632b9542fc49f098c72381/
https://snipt.net/raw/c1f36e0159632b9542fc49f098c72381/
c1f36e0159632b9542fc49f098c72381
text
Text only
5
2016-12-10T07:40:53
True
False
False
/api/public/snipt/14222/
rollback-to-previous-package-version-after-upgrade-with-ubuntu-804lts-and-apt
<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></span><span id="L-1"><a name="L-1"></a>This will show all the versions of the package in the cache </span><span id="L-2"><a name="L-2"></a>apt-cache show [package name] | fgrep Version: </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>This will install an older version of the package </span><span id="L-5"><a name="L-5"></a>apt-get install [package name]=[version] </span></pre></div> </td></tr></table>
apt, package, rollback, ubuntu

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-12-10T07:41:19
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></span><span id="L-1"><a name="L-1"></a><span class="c1"># 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="c1"># 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="c1"># 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

Symlink Python package to Python path

#!/bin/bash
ln -s `pwd`/$1 `python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`/$1
https://snipt.net/embed/71d329aa84280dc80dc5894d03c0cef4/
https://snipt.net/raw/71d329aa84280dc80dc5894d03c0cef4/
71d329aa84280dc80dc5894d03c0cef4
bash
Bash
2
2016-12-10T13:27:40
True
False
False
/api/public/snipt/880/
symlink-python-package-to-python-path
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="ch">#!/bin/bash</span> </span><span id="L-2"><a name="L-2"></a>ln -s <span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>/<span class="nv">$1</span> <span class="sb">`</span>python -c <span class="s2">&quot;from distutils.sysconfig import get_python_lib; print get_python_lib()&quot;</span><span class="sb">`</span>/<span class="nv">$1</span> </span></pre></div> </td></tr></table>
package, python, symlink
Copyrighted, illegal, or inappropriate content? Email [email protected].