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





All commands from sorted by
Terminal - All commands - 12,232 results
cat file-that-failed-to-download.zip | curl -C - http://www.somewhere.com/file-I-want-to-download.zip >successfully-downloaded.zip
2009-08-05 13:33:06
Functions: cat

If you are downloading a big file (or even a small one) and the connection breaks or times out, use this command in order to RESUME the download where it failed, instead of having to start downloading from the beginning. This is a real win for downloading debian ISO images over a buggy DSL modem.

Take the partially downloaded file and cat it into the STDIN of curl, as shown. Then use the "-C -" option followed by the URL of the file you were originally downloading.

{ u="http://twitter.com/commandlinefu"; echo "Subject: $u"; echo "Mime-Version: 1.0"; echo -e "Content-Type: text/html; charset=utf-8\n\n"; curl $u ; } | sendmail recipient@example.com
2010-02-24 04:18:30
User: pascalv
Functions: echo sendmail

This will send the web page at $u to recipient@example.com . To send the web page to oneself, recipient@example.com can be replaced by $(whoami) .

The "charset" is UTF-8 here, but any alternative charset of your choice would work.

`wget -O - -o /dev/null $u` may be considered instead of `curl $u` .

On some systems the complete path to sendmail may be necessary, for instance /sys/pkg/libexec/sendmail/sendmail for some NetBSD.

export PSOA='user,pid,time,state,command' ; function _ps { /bin/ps $@ ; } ; alias psa='_ps ax -o $PSOA'
2010-05-27 02:07:56
User: mattmartini
Functions: alias export

#ps aliases





function _ps { /bin/ps $@ ; }

alias ps='_ps ax -o $PSO'

alias psa='_ps ax -o $PSOA'

alias psl='_ps ax -o $PSOL'

alias psm='_ps -U $USER -o $PSOA'

tar -C <source> -cf - . | tar -C <destination> -xf -
svn log . --stop-on-copy
2010-02-24 12:37:18
User: reaper

The command show the log of a branch, stopping the output at the time of branch creation.

brew update && brew upgrade
xterm +u8 -fn mtx -maximized -T "There is no spoon!" -e cmatrix -bxa -u 3 & sleep .1s && wmctrl -r :ACTIVE: -b add,fullscreen && transset-df -a &
2012-09-28 04:46:28
User: bugmenot
Functions: sleep
apt-get install cmatrix cmatrix-xfont wmctrl transset-df

Need to restart computer for mtx font to work

Commands while cmatrix is running:

1 - 9 = Change speed

SHIFT + 1 - 7 = change colors

Q = Quit

Tested in Ubuntu 10.04

twistd -no web
2014-02-01 22:35:50
User: nkorth

Install twistd first with

sudo apt-get install python-twistd-web
cd /usr/ports; grep -F "`for o in \`pkg_info -qao\` ; \ do echo "|/usr/ports/${o}|" ; done`" `make -V INDEXFILE` | \ grep -i \|ports@freebsd.org\| | cut -f 2 -d \|
2009-02-16 21:07:35
User: grep
Functions: cd cut grep

only works for freeBSD where ports are installed in /usr/ports

credit to http://wiki.freebsd.org/PortsTasks

CTRL + a
export PS1='\D{%a %D %T}> '
cd -
2011-07-05 05:28:32
Functions: cd

Add dirs to list:

pushd /tmp

/tmp ~


cd -


cd -


RANGE=`wc -l /usr/share/dict/words | sed 's/^\([0-9]*\) .*$/\1/'`; for i in {1..4}; do let "N = $RANDOM % $RANGE"; sed -n -e "${N}p" /usr/share/dict/words | tr -d '\n'; done; RANGE=100; let "N = $RANDOM % $RANGE"; echo $N
while :; do cat file.txt | nc -l 80; done
vim -c'highlight Comment ctermfg=white' my.conf
2011-10-21 00:53:03
User: kev
Functions: vim
Tags: vim

you should choose proper color to make comments invisible.

Boot up destination machine with Knoppix live CD and run nc -l -p 9000 | dd of=/dev/sda Then on the master dd if=/dev/sda | nc <dest-ip> 9000 You can monitor bandwidth usage to see progress: nload eth0 -u M
2009-05-07 05:26:58
User: lv4tech
Functions: dd

This is a bit to bit copy so if you have a 500GB hard disk it will take a long time even if have Gigabit Ethernet

printf "%s\n" !(pattern) ## ksh, or bash with shopt -s extglob
2009-11-26 14:09:56
User: cfajohnson
Functions: bash printf
Tags: ls grep

There's no need for ls or grep; printf is builtin to most modern shells

echo "Terrorist threat level: `sed $(perl -e "print int rand(99999)")"q;d" /usr/share/dict/words`"
2011-01-28 09:49:37
User: houghi
Functions: echo

Numbers are less understandable then words. Also this may put out a different result.

sort -R /usr/share/dict/british | grep -v -m4 ^\{1,10\}$ | tr [:upper:] [:lower:] | tr "\n" " " | tr -d "'s" | xargs -0 echo
2011-08-16 10:11:21
User: takac
Functions: grep sort tr xargs
Tags: tr xkcd

Doesn't use shuf, its much faster with "shuf -n4" instead of sort -R

pcregrep --color -M -N CRLF -e "SQLEngine\.\w+\W*\([^\)]*\)" -r --include='\.java$'
tcpdump -s 1024 -l -A -n host
2013-02-02 22:29:52
User: wejn
Functions: host tcpdump
Tags: http tcpdump

This is a better way to do the "src X or dst X" filter; plus you might not want to bother with DNS lookups (-n).

aspell -d en dump master | aspell -l en expand > words
(echo n; echo p; echo 3; echo 1; echo; echo; echo w; echo q) | /sbin/fdisk /dev/sda
xdg-open .
2010-10-05 04:20:31
User: schlaegel

Opens the current working directory in the user's preferred application using freedesktop.org's xdg-open.

sed 's/.$//' Win-file.txt