snipt

Ctrl+h for KB shortcuts

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-09-21T18:37:44
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 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="nv">$&quot;</span><span class="s2"> || { echo &quot;</span>Not installed<span class="s2">&quot;; }</span> </span></pre></div> </td></tr></table>
apt, linux, package

Bash

add gpg key to apt keyring

url="http://www.example.com/gpg.key"
wget -O - "$url" | sudo apt-key add -
https://snipt.net/embed/14af6e64ee94a94600c79800a4daed82/
https://snipt.net/raw/14af6e64ee94a94600c79800a4daed82/
14af6e64ee94a94600c79800a4daed82
bash
Bash
2
2016-09-23T03:09:00
True
False
False
/api/public/snipt/141321/
add-gpg-key-to-apt
<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 id="L-1"><a name="L-1"></a><span class="nv">url</span><span class="o">=</span><span class="s2">&quot;http://www.example.com/gpg.key&quot;</span> </span><span id="L-2"><a name="L-2"></a>wget -O - <span class="s2">&quot;</span><span class="nv">$url</span><span class="s2">&quot;</span> <span class="p">|</span> sudo apt-key add - </span></pre></div> </td></tr></table>
apt, gpg, key, linux

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-28T02:54:28
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

Update rdiff backup for hardy 8.04

1
2
3
4
5
6
7
# in /etc/apt/sources.list
deb http://ppa.launchpad.net/rdiff-backup-pkgs/ppa/ubuntu hardy main

# in the command line
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B4A9B65E
sudo aptitude update
sudo aptitude install rdiff-backup
https://snipt.net/embed/dd8446021fab7479b44997e8831c5a14/
https://snipt.net/raw/dd8446021fab7479b44997e8831c5a14/
dd8446021fab7479b44997e8831c5a14
bash
Bash
8
2016-09-25T15:16:13
True
False
False
/api/public/snipt/30702/
add-rdiff-backup-for-hardy-804
<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"># in /etc/apt/sources.list</span> </span><span id="L-2"><a name="L-2"></a>deb http://ppa.launchpad.net/rdiff-backup-pkgs/ppa/ubuntu hardy main </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c"># in the command line</span> </span><span id="L-5"><a name="L-5"></a>sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B4A9B65E </span><span id="L-6"><a name="L-6"></a>sudo aptitude update </span><span id="L-7"><a name="L-7"></a>sudo aptitude install rdiff-backup </span></pre></div> </td></tr></table>
apt, rdiff-backup

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-09-27T17:11:45
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 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

Debian Sourcelist

Debian SourceList

deb http://security.debian.org/ lenny/updates main
deb http://ftp.debian.org/debian lenny main contrib non-free
https://snipt.net/embed/7dd2e6dd734764d9f74178e07c318ea0/
https://snipt.net/raw/7dd2e6dd734764d9f74178e07c318ea0/
7dd2e6dd734764d9f74178e07c318ea0
sourceslist
Debian Sourcelist
2
2016-09-22T17:03:00
True
False
False
/api/public/snipt/8510/
debian-sourcelist
<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 id="L-1"><a name="L-1"></a><span class="k">deb</span> <span class="s">http://security.debian.org/</span> <span class="kp">lenny/updates</span> <span class="kp">main</span> </span><span id="L-2"><a name="L-2"></a><span class="k">deb</span> <span class="s">http://ftp.debian.org/debian</span> <span class="kp">lenny</span> <span class="kp">main</span> <span class="kp">contrib</span> <span class="kp">non-free</span> </span></pre></div> </td></tr></table>
apt, debian, source

Text only

set apt-cacher proxy and temporarily disable it

1
2
3
4
5
6
7
In this example an apt-cacher proxy is running on the server at 192.168.0.2.

---- /etc/apt/apt.conf.d/01proxy:
Acquire::http::Proxy "http://192.168.0.2:3142/apt-cacher/";

Bypassing the proxy temporarily:
# apt-get install -o Acquire::http::Proxy=none ack-grep
https://snipt.net/embed/89385dbb43fd8fd9161e08100f3885f0/
https://snipt.net/raw/89385dbb43fd8fd9161e08100f3885f0/
89385dbb43fd8fd9161e08100f3885f0
text
Text only
7
2016-09-27T13:58:46
True
False
False
/api/public/snipt/6260/
set-apt-cacher-proxy-and-temporarily-disable-it
<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>In this example an apt-cacher proxy is running on the server at 192.168.0.2. </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>---- /etc/apt/apt.conf.d/01proxy: </span><span id="L-4"><a name="L-4"></a>Acquire::http::Proxy &quot;http://192.168.0.2:3142/apt-cacher/&quot;; </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a>Bypassing the proxy temporarily: </span><span id="L-7"><a name="L-7"></a># apt-get install -o Acquire::http::Proxy=none ack-grep </span></pre></div> </td></tr></table>
apt, debian, ubuntu

Bash

import PPA key

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <key id>
https://snipt.net/embed/14f9b7b4b63cffc62884bda6a07743f6/
https://snipt.net/raw/14f9b7b4b63cffc62884bda6a07743f6/
14f9b7b4b63cffc62884bda6a07743f6
bash
Bash
1
2016-09-27T18:18:29
True
False
False
/api/public/snipt/5725/
import-ppa-key
<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 id="L-1"><a name="L-1"></a>sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys &lt;key id&gt; </span></pre></div> </td></tr></table>
apt, gpg, ubuntu
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.