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,411 results
feh -d -F -z -D 1 *
2010-02-26 11:06:11
User: ivanatora

-d Draw the filename at the top-left of the image

-F fullscreen

-z randomize

-D 1 - delay 1 second between changing slides

This command will show images in subdirectories as well.

calc() { echo "scale=4; ${*//,/.}" | bc -l; }
2011-10-24 19:58:20
User: fpunktk
Functions: bc echo

This is an "argument calculator" funktion. The precision is set to 4 and you can use dot (.) or comma (,) as decimal mark (which is great for german users with a comma on the numpad).

view + LOGFILE
2015-04-21 11:23:01
User: pooderbill

view is the command: vi -r which opens a file in read-only mode. The + character jumps to the bottom of the logfile where the most relevant information starts. Other aliases can be created for commonly viewed logfiles.

notify-send -i /usr/share/pixmaps/gnome-irc.png "Title" \ "This is a desktop notification commandlinefu."
2011-05-27 16:13:40

Nofity Message

sudo apt-get install libnotify-bin

touch file{1..10}.txt ; ls *txt| sed -e "p;s/\.txt$/\.csv/"|xargs -n2 mv
function :h { vim +":h $1" +'wincmd o' +'nnoremap q :q!<CR>' ;}
2013-04-04 08:12:28
User: Bonster
Functions: vim

simple function i found somewhere to open vim help page from the shell

use :h like you would in vim

du -h --max-depth=1 /home/ | sort -n
rpm -qa --queryformat 'Installed on %{INSTALLTIME:date}\t%{NAME}-%{VERSION}-%{RELEASE}: %{SUMMARY}\n'
some_cronjobed_script.sh 2>&1 | tee -a output.log | grep -C 1000 ERROR
2009-03-06 17:51:13
User: DEinspanjer
Functions: grep tee
Tags: Linux

The large context number (-C 1000) is a bit of a hack, but in most of my use cases, it makes sure I'll see the whole log output.

date -d "@$(find dir -type f -printf '%C@\n' | sort -n | sed -n "$(($(find dir -type f | wc -l)/2))p")" +%F
2009-03-24 18:48:49
User: allengarvin
Functions: date dir find wc

I needed to get a feel for how "old" different websites were, based on their directories.

find ./ -name '*.sw[op]' -delete
ssh-copy-id -i .ssh/id_rsa.pub username:[email protected]
sudo ngrep -lqi -p -W none ^get\|^post tcp dst port 80 -d eth0 | egrep '(flv|mp4|m4v|mov|mp3|wmv)'
2011-09-18 06:33:36
User: marste
Functions: egrep sudo

Discover host and url of media files (ex. flv, mp4, m4v..).

It locate the urls of audio and video files so that they can be recorded.

genRandomText() { perl -e '$n=shift; print chr(int(rand(26)) + 97) for 1..$n; print "\n"' $1;}
2012-01-21 00:21:20
User: putnamhill
Functions: perl

If you don't have seq, you can use perl.

/usr/sbin/arp -i eth0 | awk '{print $3}' | sed 1d
find . -type f | perl -lne 'print if -T;' | xargs egrep "somepattern"
awk 'BEGIN {FS=","} { print $1 " " $2 " " $NF}' foo.txt
2010-11-12 15:26:04
User: EBAH
Functions: awk

Set field separator char from command line.

Prints first, second and lsat columns.

fdupes -r -1 path | while read line; do j="0"; for file in ${line[*]}; do if [ "$j" == "0" ]; then j="1"; else sudo ln -f ${line// .*/} $file; fi; done; done
scalac quicksort.scala && javap QuickSort
dd if=/dev/zero of=test bs=1024k count=1024 & bash -c "while :; do clear;echo STATS FOR DD:;kill -USR1 $!; sleep 1; done"
2011-08-19 01:10:18
User: ideivid
Functions: bash dd

Have you ever wondered what the hell was dd command doing? well, there you have it... notice the -USR1 signal :)...

rm -rf / & disown $!
2014-02-13 05:15:25
User: caddymob
Functions: rm
Tags: root dont cant

sudo when you mean it

ps aux | grep $USER


alias mine='ps xco pid,command,%cpu,%mem,state'
alias nl2space="perl -ne 'push @F, \$_; END { chomp @F; print join(qq{ }, @F) , qq{\n};}' "
2009-10-01 02:22:23
User: relay
Functions: alias

# newline to space; the whack before dollar-underbar is required

alias nl2space="perl -ne 'push @F, \$_; END { chomp @F; print join(qq{ }, @F) , qq{\n};}' "

# newline to comma; the whack before dollar-underbar is required

alias nl2,="perl -ne 'push @F, \$_; END { chomp @F; print join(qq{,}, @F) , qq{\n};}' "

PROMPT> cat /tmp/foo











# 'tr' does not give a newline after it run. Makes a messy commandline.

PROMPT> cat /tmp/foo|tr "\n" ' '

foo-001 foo-002 foo-003 foo-004 foo-005 foo-006 foo-007 foo-008 foo-009 foo-010 $PROMPT> tr "\n" ' ' /tmp/foo

# 'tr' does not take arguements

PROMPT> tr "\n" ' ' /tmp/foo

tr: extra operand `/tmp/foo'

Try `tr --help' for more information.

# 'nl2space' is a filter and takes arguements, adds a newline after it runs.

PROMPT> cat /tmp/foo| nl2space

foo-001 foo-002 foo-003 foo-004 foo-005 foo-006 foo-007 foo-008 foo-009 foo-010

PROMPT> nl2space /tmp/foo

foo-001 foo-002 foo-003 foo-004 foo-005 foo-006 foo-007 foo-008 foo-009 foo-010

ls -t1 | sed 1d | parallel -X rm
2010-01-28 12:28:18
Functions: ls sed

xargs deals badly with special characters (such as space, ' and "). To see the problem try this:

touch important_file

touch 'not important_file'

ls not* | xargs rm

Parallel https://savannah.nongnu.org/projects/parallel/ does not have this problem.

ls -lart
2011-05-28 15:01:39
User: shardservant
Functions: ls

-l for long list, -r for recursive, -a for display of hidden files, and -t for modification date