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.

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



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

All commands from sorted by
Terminal - All commands - 12,378 results
find . -type f -exec sed -i 's/gw10./gw17./g' {} \;
cowsay -l | sed '1d;s/ /\n/g' | while read f; do cowsay -f $f $f;done
find . \( -name "*.as[pc]x" -o -name "*.htm*" \) -exec grep -Hi "jquery-1" {} +
zc () { for exp in $argv; do print "$exp = $(( exp ))"; done; }
find . -type f -name '*.gz'|awk '{print "zcat", $1, "| bzip2 -c >", $0.".tmp", "&& rename", "s/.gz.tmp/.bz2/", "*.gz.tmp", "&& rm", $0}'|bash
2013-04-11 10:17:57
User: Ztyx
Functions: awk find

This solution is similar to [1] except that it does not have any dependency on GNU Parallel. Also, it tries to minimize the impact on the running system (using ionice and nice).

[1] http://www.commandlinefu.com/commands/view/7009/recompress-all-.gz-files-in-current-directory-using-bzip2-running-1-job-per-cpu-core-in-parallel

cat /service/solr/log/main/current | tai64nlocal | grep "\(`date '+%F %H'`\|`date '+%F %H %M' | awk '{print $1" 0"$2-1":"$3}'`\)" | grep QTime | awk '{print $NF}' | awk -F\= '{ s += $2} END {print s/NR}'
ifconfig | grep -B 1 "inet addr:" | head -1 | cut -d" " -f1
2010-01-04 23:02:57
User: jasonwalsh
Functions: cut grep head ifconfig

Get the line containing "inet addr:" and the line before that, get down to only the first line, and then get the first word on that line, which should be the interface.

ifconfig eth0 | grep "inet:" | cut -d ":" -f2 | cut -d " " -f1
plink -v -ssh -N -D 8580 -l USERNAME -pw PASSWARD
gzip -c source.csv > source.csv.gz
2012-10-17 18:31:51
User: cfunz
Functions: gzip
Tags: gzip aix

use this command to gzip the file and write to stdout and from the stdout redirect to the another file

grep -r "sampleString" . |uniq | cut -d: -f1 | xargs sed -i "/sampleString/d"
2009-02-09 20:21:30
User: sk1418
Functions: cut grep sed xargs

checking files in current and sub directories, finding out the files containing "sampleString" and removing the containing lines from the file.

* Beware that The command will update the original file [no backup].

The command can be extended if play with 'find' command together,

e.g. it is possible to execute on certain type of files: *.xml, *.txt... (find -name "*.xml" | grep....)

if anybody knows a better solution on that, please drop a comment. thx.

ls /some/directory | sed -rn -e 's/input_file_regex/mv -v & output_file_name/p' | sh
2009-03-25 09:20:15
User: polar
Functions: ls sed
Tags: bash sed

Allows for quick mass renaming, assuming the user has some familiarity with regular expressions. Basically, it replaces the original_file_name in the output of ls with

"mv -v original_file_name new_file_name"

and passes the output to sh.

feh --bg-center `ls -U1 |sort -R |head -1`
FECHA=$(date +"%F") FINAL="$FECHA.sql.gz" mysqldump -h localhost -u user --password="pass" --opt jdiaz61_lupajuridica | gzip > /home/jdiaz61/www/backup/$FINAL
2009-08-09 14:51:46
User: juancabo
Functions: date gzip

Tres lineas en un shell script para copiar la base de datos diaramente

find . type f -exec echo http://exg.com/{} \; > file
2010-03-02 14:18:01
Functions: echo find type

find all files in cur dir add to url and append to file

feh --bg-center `ls | shuf -n 1`
wget --mirror -A.jpg http://www.xs4all.nl/~dassel/wall/
ifdata -pN eth0
route -n | awk '$2 ~/[1-9]+/ {print $2;}'
2010-08-08 23:51:07
User: kerim
Functions: awk route

Find your default gateway and print it directly output


[email protected]

zpool create tank raidz c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0
2009-05-16 10:44:05
User: mnikhil

The following command creates a pool with a single raidz root vdev that consists of six disks.

sudo ifconfig -a | grep eth | grep HW | cut -d' ' -f11
curl http://www.chisono.it/ip.asp
screen -r irc || screen -S irc irssi
2012-10-19 12:12:54
User: daneoshiga
Functions: screen
Tags: bash screen irssi

Tries to reattach to screen, if it's not available, creates one.

created an alias "irc" for it, since sometimes i forget if there already is a screen session running with irssi, this way I avoid creating a new one by mistake.

nano `which script`
2009-02-05 16:57:41
User: fzero

Substitute nano with your favorite editor, of course.