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,273 results
grep -E ":(`cat bnd-ips.txt | sed 's/\./\\./g' | tr '\n' '|'`)" access.log
2009-07-30 12:54:55
User: Cowboy
Functions: grep

bnd-ips.txt is a list of IP adresses that is concenated for use as regular expression. Yes, this is still very speedy ;=)

find . -type f -name "*.c" -exec cat {} \; | wc -l
2009-07-30 10:06:51
User: foremire
Functions: cat find wc

use find to grep all .c files from the target directory, cat them into one stream, then piped to wc to count the lines

sed '/^#.*DEBUG.*/ s/^#//' $FILE
sed -i 's/^.*DEBUG.*/#&/' $file
cat file | tee >> file
2009-07-30 07:34:03
User: GeckoDH
Functions: cat file tee

The command `cat file >> file` failes with the following error message:

cat: file: input file is output file

`tee` is a nice workaround without using any temporary files.

rxvt-unicode -g 999x999 -sr -depth 32 -bg rg-ba:0000/0000/0000/dddd +sb -T irssi -n irssi -name irssichat -e ssh server.com -Xt screen -aAdr -RR irssi irssi
2009-07-30 04:53:17
User: MTecknology
Functions: screen ssh

This will launch and irssi session on your server. If it's not running, it will create the session. If it's running it'll connect to it and destroy any other connections. If compositing is available, the rxvt window will have transparency added. This window will also open maximized. Anything else this does should be easily figured out in the man pages.

equery s | sed 's/(\|)/ /g' | sort -n -k 9 | gawk '{print $1" "$9/1048576"m"}'
2009-07-30 01:12:10
User: Alanceil
Functions: gawk sed sort

On a Gentoo system, this command will tell you which packets you have installed and sort them by how much space they consume. Good for finding out space-hogs when tidying up disk space.

cat /proc/net/ip_conntrack | grep ESTABLISHED | grep -c -v ^#
man -t man | ps2pdf - > man.pdf
renice 19 -p $$
recode ..HTML < file.txt > file.html
apachectl restart
apache2ctl graceful
dpkg --get-selections | grep -v deinstall | cut -f 1
2009-07-29 14:37:36
User: odoepner
Functions: cut grep

Should work on all systems that use dpkg and APT package management.

ls -pt1 | sed '/.*\//d' | sed 1d | xargs rm
2009-07-29 13:59:58
User: patko
Functions: ls sed xargs

Useful for deleting old unused log files.

mount -F hsfs -o ro `lofiadm -a /sol-10-u7-ga-sparc-dvd.iso` /mnt
2009-07-29 13:56:25
User: apaton
Functions: mount


umount /mnt

Delete loopback file device

lofiadm -d /dev/lofi/1
ls -t1 | head -n1 | xargs tail -f
ipconfig getpacket en0 | grep yi| sed s."yiaddr = "."en0: ". ipconfig getpacket en1 | grep yi| sed s."yiaddr = "."en1: ".
for file in *.001; do NAME=`echo $file | cut -d. -f1,2`; cat "$NAME."[0-9][0-9][0-9] > "$NAME"; done
2009-07-29 10:04:26
User: jaymzcd
Functions: cat cut file

If you use newsgroups then you'll have come across split files before. Joining together a whole batch of them can be a pain so this will do the whole folder in one.

oggenc --tracknum='track' track.cdda.wav -o 'track.ogg'
cdparanoia -B
2009-07-29 07:56:12
User: hemanth
Functions: cdparanoia

Rip audio tracks from CD to wav files in current dir

alias vi='emacsclient -n'
2009-07-29 06:18:40
User: freestyler
Functions: alias

add (server-start) in .emacs

svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' | sort | uniq -c | sort -r
2009-07-29 02:10:45
User: askedrelic
Functions: awk egrep ls sort uniq xargs
Tags: svn count

I'm working in a group project currently and annoyed at the lack of output by my teammates. Wanting hard metrics of how awesome I am and how awesome they aren't, I wrote this command up.

It will print a full repository listing of all files, remove the directories which confuse blame, run svn blame on each individual file, and tally the resulting line counts. It seems quite slow, depending on your repository location, because blame must hit the server for each individual file. You can remove the -R on the first part to print out the tallies for just the current directory.