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,274 results
google docs edit --title "To-Do List" --editor vim
2010-06-21 16:15:42
User: spiffwalker
Tags: google

Google just released a new commend line tool offering all sorts of new services from the commend line. One of them is uploading a youtube video but there are plenty more google services to interact with.

Download it here: http://code.google.com/p/googlecl/

Manual: http://code.google.com/p/googlecl/wiki/Manual

This specific command courtesy of lifehacker:http://lifehacker.com/5568817/

Though all can be found in manual page linked above.

du -b --max-depth 1 | sort -nr | perl -pe 's{([0-9]+)}{sprintf "%.1f%s", $1>=2**30? ($1/2**30, "G"): $1>=2**20? ($1/2**20, "M"): $1>=2**10? ($1/2**10, "K"): ($1, "")}e'
until !!; do :; done
ssh root@remote.host "rpm -qa" | xargs yum -y install
lsmod | perl -e 'print "digraph \"lsmod\" {";<>;while(<>){@_=split/\s+/; print "\"$_[0]\" -> \"$_\"\n" for split/,/,$_[3]}print "}"' | dot -Tpng | display -
2011-11-27 14:02:35
User: bandie91
Functions: dot lsmod perl

parse `lsmod' output and pass to `dot' drawing utility then finally pass it to an image viewer

cat /dev/urandom | hexdump -C | grep "ca fe"
2010-09-27 08:20:44
Functions: cat grep hexdump

just make some data scrolling off the terminal. wow.

curl ifconfig.me
find . -type d -empty -delete
diff <(lsof -p 1234) <(sleep 10; lsof -p 1234)
2010-03-15 22:55:32
User: zlemini
Functions: diff sleep

This command takes a snapshot of the open files for a PID 1234 then waits 10 seconds and takes another snapshot of the same PID, it then displays the difference between each snapshot to give you an insight into what the application is doing.

watch -n 1 'echo "obase=2;`date +%s`" | bc'
cp file.txt{,.bak}
2009-01-26 12:11:29
User: root
Functions: cp

Uses shell expansion to create a back-up called file.txt.bak

for I in $(mysql -e 'show databases' -s --skip-column-names); do mysqldump $I | gzip > "$I.sql.gz"; done
wget -r -l1 --no-parent -nH -nd -P/tmp -A".gif,.jpg" http://example.com/images
2009-01-27 17:31:22
User: root
Functions: wget

This recursively downloads all images from a given website to your /tmp directory. The -nH and -nd switches disable downloading of the directory structure.

cp /work/host/phone/ui/main.cpp !#$:s/host/target
2011-09-20 06:48:07
User: kev
Functions: cp
Tags: !!

expand to:

cp /work/host/phone/ui/main.cpp /work/target/phone/ui/main.cpp


The entire command line typed so far.

echo "tee can split a pipe in two"|tee >(rev) >(tr ' ' '_')
2010-08-14 20:38:59
User: axelabs
Functions: echo tee tr

Tee can be used to split a pipe into multiple streams for one or more process to work it. You can add more " >()" for even more fun.

knock <host> 3000 4000 5000 && ssh -p <port> user@host && knock <host> 5000 4000 3000
2009-07-28 14:08:01
User: din7
Functions: ssh

Knock on ports to open a port to a service (ssh for example) and knock again to close the port. You have to install knockd.

See example config file below.


logfile = /var/log/knockd.log


sequence = 3000,4000,5000

seq_timeout = 5

command = /sbin/iptables -A INPUT -i eth0 -s %IP% -p tcp --dport 22 -j ACCEPT

tcpflags = syn


sequence = 5000,4000,3000

seq_timeout = 5

command = /sbin/iptables -D INPUT -i eth0 -s %IP% -p tcp --dport 22 -j ACCEPT

tcpflags = syn

find . -name "*.[ch]" -exec grep -i -H "search pharse" {} \;
2009-05-06 15:22:49
User: bunedoggle
Functions: find grep
Tags: find grep

I have a bash alias for this command line and find it useful for searching C code for error messages.

The -H tells grep to print the filename. you can omit the -i to match the case exactly or keep the -i for case-insensitive matching.

This find command find all .c and .h files

2009-04-08 21:25:06
User: pyrho
Tags: vim

Very handy to bring the word currently under the cursor into a :s command in Vim.


If the cursor was on the word "eggs":

:s/ ==> :s/eggs

wget -qO - http://infiltrated.net/blacklisted|awk '!/#|[a-z]/&&/./{print "iptables -A INPUT -s "$1" -j DROP"}'
2009-02-18 16:08:23
User: sil
Functions: wget

Blacklisted is a compiled list of all known dirty hosts (botnets, spammers, bruteforcers, etc.) which is updated on an hourly basis. This command will get the list and create the rules for you, if you want them automatically blocked, append |sh to the end of the command line. It's a more practical solution to block all and allow in specifics however, there are many who don't or can't do this which is where this script will come in handy. For those using ipfw, a quick fix would be {print "add deny ip from "$1" to any}. Posted in the sample output are the top two entries. Be advised the blacklisted file itself filters out RFC1918 addresses (10.x.x.x, 172.16-31.x.x, 192.168.x.x) however, it is advisable you check/parse the list before you implement the rules

mkdir -p work/{d1,d2}/{src,bin,bak}
2009-05-12 14:36:42
User: fritz_monroe
Functions: export

History usually only gives the command number and the command. This will add a timestamp to the history file.

Note: this will only put the correct timestamp on commands used after the export is done. You may want to put this in your .bashrc

find ./ -type f -exec chmod 644 {} \;
lsof -i tcp:80
2009-04-16 14:51:53
User: ar_levi

Sometimes you need to use a port that is already opened by some program , and you don't know who to "kill" for it to release - so, now you do !

leave +15
2009-03-13 06:09:52
User: haivu
Tags: PIM

If you spend most of your time in front of the terminal, leave is a useful reminder. Leave can have absolute form: leave 1555 reminds you to leave at 3:55PM

showkey -a