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.

Universal configuration monitoring and system of record for IT.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





Commands by ioggstream from sorted by
Terminal - Commands by ioggstream - 28 results
netstat -town
ip -o -4 a s
2012-09-19 10:59:05
User: ioggstream

Short list of all ip.

Shows even the newly supported multiple ip address on the same interface (see eth1).

For ipv6 use -6

ldapsearch -xLLL -b "cn=schema" "(objectclass=*)" \ \* objectclasses attributetypes | perl -p0e 's/\n //g'
2012-04-04 13:31:31
User: ioggstream
Functions: perl

Dump 389ds schema, putting "\n " on one line with perl.

You have to specify the objectclasses, attributetypes operational attributes too, otherwise they won't be dumped!

<ESC> #
2011-09-13 17:01:44
User: ioggstream

This should work with different locales. Another post reports

awk '{print $0/60;}' /proc/uptime
2011-08-31 10:41:21
User: ioggstream
Functions: awk

Get info directly from /proc/uptime

list the naming contexts of a directory server (no need to search in config files)
ps -ef | grep c\\ommand
grep -i "$*" /usr/lib/perl5/Unicode/CharName.pm | while read a b; do /usr/bin/printf "\u$a\tU+%s\t%s\n" "$b"; done
2011-01-04 11:30:16
User: ioggstream
Functions: grep read

No need for further filedes or substitution for splitting. Simply use read a b

nmap -v -sP | grep -c down
wall <<< "Broadcast This"
pgrep -c cat
find -iname \*.[ch] -exec emacs -nw -q {} --eval "(progn (mark-whole-buffer) (indent-region (point-min) (point-max) nil) (save-buffer))" --kill \;
2010-09-10 12:24:58
User: ioggstream
Functions: emacs find

use -iname \*[.ch] instead of -iname \*.c -o -iname \*.h

pgrep -cu ioggstream
diff -wubBEr -x .svn dirA dirB
shuf -i 1-49 | head -n6 | sort -n| xargs
2009-10-22 12:54:08
User: ioggstream
Functions: head sort

note the xargs at the end

tar dfz horde-webmail-1.2.3.tar.gz
perl -ne 'split /,/ ; $a+= $_[3]; END {print $a."\n";}' -f ./file.csv
ulimit -s 64
2009-08-06 10:40:25
User: ioggstream
Functions: ulimit
Tags: Linux ulimit

default stack size is 10M. This makes your multithread app filling rapidly your memory.

on my PC I was able to create only 300thread with default stack size.

Lower the default stack size to the one effectively used by your threads, let you create more.

ex. putting 64k I was able to create more than 10.000threads.

Obviously ...your thread shouldn't need more than 64k ram!!!

ldapmodify -Y "dn:uid=rob,dc=example.com" -g -R -J 2.16.840.1.113730.3.4.16 ...
$ grep -or string path/ | wc -l
export HISTCONTROL=ignoreboth
2009-07-15 16:05:03
User: ioggstream
Functions: export
Tags: history

Don't track in history commands starting with whitespace.

Moreover ignore duplicates from history.

To be set in .bashrc


$ export HISTCONTROL=ignoreboth

$   echo antani

$   history|grep -c antani

export LANG=C; grep string longBigFile.log
2009-07-14 12:48:02
User: ioggstream
Functions: export grep
Tags: grep LANG

greps using only ascii, skipping the overhead of matching UTF chars.

Some stats:

$ export LANG=C; time grep -c Quit /var/log/mysqld.log


real 0m0.191s

user 0m0.112s

sys 0m0.079s

$ export LANG=en_US.UTF-8; time grep -c Quit /var/log/mysqld.log


real 0m13.462s

user 0m9.485s

sys 0m3.977s

Try strace-ing grep with and without LANG=C

pkill -9 -f program
2009-07-12 14:46:14
User: ioggstream
Tags: kill pgrep pkill

Kills a process matching program. I suggest using

$ pgrep -fl program

to avoid over-killings

Nice the following: kills all bash process owned by guest

$ pkill -9 -f bash -u guest

egrep --color=auto 'usb|' /var/log/messages
2009-07-08 15:20:31
User: ioggstream
Functions: egrep

this is useful to highlight only some code without losing other lines (eg. software, logs, scripts)

du -ms * .[^.]*| sort -nk1
2009-07-01 13:38:13
User: ioggstream
Functions: du sort

using mb it's still readable;) a symbol variation

$ du -ms {,.[^.]}* | sort -nk1