Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands tagged Debian from sorted by
Terminal - Commands tagged Debian - 85 results
aptitude search ~i -F %p
2011-10-15 00:31:10
User: dbbolton
0

This will print the name of every installed package on a Debian system.

sudo dpkg -i `ls -tr *.deb | tail -n4`
2011-10-09 14:20:11
User: _john
Functions: sudo tail
0

after kernel build with make deb-pkg, I like to install the 4 newest packages that exist in the directory. Beware: might be fewer for you....

apt-get remove $(dpkg -l | awk "/^ii linux-(image|headers)/ && ! /`uname -r`/ {print \$2}")
2011-10-09 13:58:47
User: _john
Functions: apt awk
0

since awk was already there one can use it instead of the 2 greps. might not be faster, but fast enough

debconf-copydb copydb configdb --config="Name: copydb" --config ="Driver: File" --config="Filename: ~/copydebconf.dat"
debconf-copydb configdb copydb --pattern=<PACKAGE> --config="Name: copydb" --config="Driver: File" --config="Filename: ~/copydebconf.dat"
apt-cache policy mythtv
2011-08-05 17:34:41
User: PLA
Functions: apt
-2

Use this command to determine what version of MythTV you are running on a Debian system. Tested on a Mythbuntu installation.

aptitude search ~d<string>
2011-08-02 05:19:13
-1

Especially useful for latex packages, which are listed in the description of their Ubuntu package E.g. say I want to find the Ubuntu package containing latex package aeguill:

aptitude search ~daeguill

p texlive-lang-french - TeX Live: French

ssh remotehost 'dpkg --get-selections' | dpkg --set-selections && dselect install
2011-05-12 17:26:43
User: Mozai
Functions: ssh
22

(also works on Ubuntu) Copies the 'install,' 'hold,' 'deinstall' and 'purge' states of packages on the remote machine to be matched on the local machine. Note: if packages were installed on the local machine that were never installed on the remote machine, they will not be deinstalled by this operation.

sudo aptitude remove -P $(dpkg -l|awk '/^ii linux-image-2/{print $2}'|sed 's/linux-image-//'|awk -v v=`uname -r` 'v>$0'|sed 's/-generic//'|awk '{printf("linux-headers-%s\nlinux-headers-%s-generic\nlinux-image-%s-generic\n",$0,$0,$0)}')
2011-04-25 05:19:57
User: Bonster
Functions: awk sed sudo
-1

Same as 7272 but that one was too dangerous

so i added -P to prompt users to continue or cancel

Note the double space: "...^ii␣␣linux-image-2..."

Like 5813, but fixes two bugs: [1]This leaves the meta-packages 'linux-headers-generic' and 'linux-image-generic' alone so that automatic upgrades work correctly in the future. [2]Kernels newer than the currently running one are left alone (this can happen if you didn't reboot after installing a new kernel).

trickle sudo apt-get update -y
sudo apt-get -o Acquire::http::Dl-Limit=20 -o Acquire::https::Dl-Limit=20 upgrade -y
2011-02-14 05:24:49
User: ruslan
Functions: sudo
2

in Debian-based systems apt-get could be limited to the specified bandwidth in kilobytes using the apt configuration options(man 5 apt.conf, man apt-get). I'd quote man 5 apt.conf:

"The used bandwidth can be limited with Acquire::http::Dl-Limit which accepts integer values in kilobyte. The default value is 0 which deactivates the limit and tries uses as much as possible of the bandwidth..."

"HTTPS URIs. Cache-control, Timeout, AllowRedirect, Dl-Limit and proxy options are the same as for http..."

dpkg -S $( which ls )
dpkg -l python
2011-01-05 06:15:13
User: hackerb9
1

If the first two letters are "ii", then the package is installed. You can also use wildcards. For example,

.

dpkg -l openoffice*

.

Note that dpkg will usually not report packages which are available but uninstalled. If you want to see both which versions are installed and which versions are available, use this command instead:

.

apt-cache policy python
ar -x package.deb
awk '{if ($1 ~ /Package/) p = $2; if ($1 ~ /Installed/) printf("%9d %s\n", $2, p)}' /var/lib/dpkg/status | sort -n | tail
aptitude remove $(dpkg -l|awk '/^ii linux-image-2/{print $2}'|sed 's/linux-image-//'|awk -v v=`uname -r` 'v>$0'|sed 's/-generic//'|awk '{printf("linux-headers-%s\nlinux-headers-%s-generic\nlinux-image-%s-generic\n",$0,$0,$0)}')
2010-12-11 11:38:15
User: __
Functions: awk sed
7

Note the double space: "...^ii␣␣linux-image-2..."

Like 5813, but fixes two bugs: [1]This leaves the meta-packages 'linux-headers-generic' and 'linux-image-generic' alone so that automatic upgrades work correctly in the future. [2]Kernels newer than the currently running one are left alone (this can happen if you didn't reboot after installing a new kernel).

I'm bummed that this took 228 characters. I'd like to see a simpler version.

supportsWrap(){ ldd `which ${1}` | grep "libwrap" &>/dev/null && return 0 || return 1; }
2010-12-01 15:22:29
User: cicatriz
Functions: grep ldd return
Tags: vim Debian ldd
1

This function returns TRUE if the application supports tcp-wrapping or FALSE if not by reading the shared libraries used by this application.

dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
dpkg -l | grep ^rc | cut -d' ' -f3 | xargs dpkg -P
dlocate /path/to/file
2010-11-18 19:07:12
User: towo
7

Works similar to dpkg -S, but uses the locatedb and is thus inarguably a lot faster - if the locatedb is current.

sudo apt-add-repository 'deb http://archive.offensive-security.com pwnsauce main microverse macroverse restricted universe multiverse' && wget -q http://archive.offensive-security.com/backtrack.gpg -O- | sudo apt-key add -
2010-11-16 18:23:48
User: kzh
Functions: sudo wget
Tags: Debian
3

Add the BackTrack repositories to your Debian based GNU/Linux distribution. Thanks to http://it-john.com/home/technology/linux-technology/add-back-track-4-repo-to-ubuntu/

aptitude purge '~c'
sudo dpkg-reconfigure -a
axi-cache search <searchterm>
2010-07-05 00:16:03
User: tarkasteve
0

A replacement for 'apt-cache' that uses a Xapian to produce ranked results. Available in 'apt-xapian-index' 0.27 and higher.