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
pdftk 1.pdf 2.pdf cat output 12.pdf
git checkout HEAD~2 -- /path/to/dir
scrot -d 3 '/tmp/%Y-%m-%d_$wx$h.png' -e 'cat $f'|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*"
2012-11-13 21:16:09
User: dzup
Functions: grep

That its my personal key that i dont use, if you want yours, go to imgur and get it, or use that one

alias gfind='find . -print0 | xargs -0 egrep -I '
gem install -g
mysql -s -e "show processlist" |awk '{print $1}'
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 ;=)

vmstat 2 10 | awk 'NR > 2 {print NR, $13}' | gnuplot -e "set terminal png;set output 'v.png';plot '-' u 1:2 t 'cpu' w linespoints;"
ls -lth podcasts/
alias screenr='screen -r $(screen -ls | egrep -o -e '[0-9]+' | head -n 1)'
cd() { if [ -n "$1" ]; then [ -f "$1" ] && set -- "${1%/*}"; else [ -n "$CDDIR" ] && set -- "$CDDIR"; fi; command cd "$@"; }
2011-06-24 08:48:13
User: flatcap
Functions: cd command set
Tags: cd test set

Move efficiently between directories.


This command adds a couple of extra features to cd, without affecting normal use.

CDPATH use is also unaffected. It introduces and environment variable CDDIR which is used as an alternate home directory.


Note: I don't want to alter $HOME because then all my dot files will move.




cd dir

Change directory to "dir" (using CDPATH if necessary)


cd dir/file.txt

Change directory to "dir" (containing folder of "file.txt")

This allows you to cut'n'paste, or use


CDDIR is unset


Change directory to $HOME




Change directory to /home/flatcap/work


For convenience, put the command, and the following, in your .bashrc or .bash_profile

export CDDIR="/home/flatcap/work"

alias cdd="CDDIR=$(pwd)"

find . -type l | (while read FN ; do test -e "$FN" || ls -ld "$FN"; done)
curl --ntlm -u <your Active-Directory-Domain>/<your-domain-username> -T /path/to/local/$FILE http://sharepoint.url.com/doc/library/dir/
2011-09-08 18:08:58
User: barnesmjsa

Use Curl to upload documents from your linux servers to MS Sharepoint servers.

git remote | xargs -n 1 git push
pdftk A=1.pdf B=2.pdf C=3.pdf cat C A output CA.pdf
find -type l | xargs ls -l
du -sh /home/*|sort -rh|head -n 10
2012-09-12 11:54:06
User: toaster
Functions: du head sort

the -h option of du and sort (on appropriate distrib) makes output "Human" readable and still sorted by "reversed size" (sort -rh)

for host in $MYHOSTS; do ping -q -c3 $H 2>&1 1>/dev/null && ssh -o 'AllowedAuthe ntications publickey' $host 'command1; command2' & for count in 1 2 3 4 5; do sleep 1; jobs | wc -l | grep -q ^0\$ && continue; done; kill %1; done
2012-11-13 23:12:27
User: a8ksh4
Functions: grep host jobs kill ping sleep ssh wc

Execute commands serially on a list of hosts. Each ssh connection is made in the background so that if, after five seconds, it hasn't closed, it will be killed and the script will go on to the next system.

Maybe there's an easier way to set a timeout in the ssh options...

wget -O - "[PICASA ALBUM RSS LINK]" |sed 's/</\n</g' | grep media:content |sed 's/.*url='"'"'\([^'"'"']*\)'"'"'.*$/\1/' |awk -F'/' '{gsub($NF,"d/"$NF); print $0}'|wget -i -
dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' `aptitude --display-format '%p' search '?installed!?automatic'` | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}'
2013-07-26 23:18:20
User: EvilDennisR
Functions: awk grep sort

The other commands were good, but they included packages that were installed and then removed.

This command only shows packages that are currently installed, sorts smallest to largest, and formats the sizes to be human readable.

:set number
2013-10-07 15:03:52
User: sonic
Tags: vim vi

Prints line numbers making it easier to see long lines that wrap in your terminal and extra line breaks at the end of a file.

:set nu

works too.

find . -name "*.DS_Store" -type f -delete
touch /forcefsk
(cd SRC; find . -type d -exec mkdir TARGET/{} ";"; find . -type f -exec mv {} TARGET/{} ";")
2009-08-17 12:35:48
User: karel1980
Functions: cd find mkdir mv

Using a GUI file managers you can merge directories (cut and paste). This command roughly does the same (it doesn't ask for confirmation (no problem for me) and it doesn't clean up the empty SRC directories (no problem, trivial).

probably does the same:

cp -l SRC TARGET; rm -rf SRC