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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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,447 results
svn diff --diff-cmd='meld' -r 100:BASE FILE
free -m | awk '/cache:/ {print $4}'
2012-03-13 19:54:26
User: felixhummel
Functions: awk free
Tags: ram free

Does not output the word "shared" so you can easily store this number in a variable.

curl -s http://people.mozilla.com/~faaborg/files/shiretoko/firefoxIcon/firefox-64.png | convert - jpg:- | jp2a --color --html -> firefox.html
cat list.txt | pax -wd > archive.tar
gzip -cd gzippedarchive.tar.gz | tar -xf -
2013-09-18 17:41:25
User: RAKK
Functions: gzip tar
Tags: gzip aix

This command is for UNIX OSes that have plain vanilla System V UNIX commands instead of their more functional GNU counterparts, such as IBM AIX.

find . -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
echo "$(( $(( $(grep 'physical id' '/proc/cpuinfo' | uniq | wc -l) * $(grep 'core id' '/proc/cpuinfo' | wc -l) )) * 2 + 1 ))"
2015-11-14 20:44:39
User: snorf
Functions: echo
Tags: uniq

shell order of operation example which calculates:

x = number of physical CPU's

y = number of cores per CPU

2(x * y) + 1 = CPU load limit

useradd -s /sbin/nologin nicdev
wget -qO - http://www.commandlinefu.com/feed/tenup | xmlstarlet sel -T -t -o '<x>' -n -t -m rss/channel/item -o '<y>' -n -v description -o '</y>' -n -t -o '</x>' | xmlstarlet sel -T -t -m x/y -v code -n
2009-08-14 02:44:00
User: fsilveira
Functions: wget

This lengthy cryptic line will print the latest top 10 commandlinefu.com posts without their summaries. To print also their respective summaries use the following (even bigger) command line:

wget -qO - http://www.commandlinefu.com/feed/tenup | xmlstarlet sel -T -t -o '<doc>' -n -t -m rss/channel/item -o '<item>' -n -o '<title>' -v title -o '</title>' -n -o '<description>' -v description -o '</description>' -n -o '</item>' -n -t -o '</doc>' | xmlstarlet sel -T -t -m doc/item -v description/code -n -v title -n -n

It is recommended to include this line into a shell script to be easily run, as I do myself. You could also use the following URLs to browse the top 3 commands:

wget -qO - http://www.commandlinefu.com/feed/threeup | xmlstarlet ...

.. or all others:

wget -qO - http://feeds2.feedburner.com/Command-line-fu | xmlstarlet ...

PS: You need to install "xmlstarlet" to run it. It is found in Debian APT repositories (apt-get install xmlstarlet) or under the http://xmlstar.sourceforge.net/ URL.

echo $RANDOM$RANDOM$RANDOM |cut -c3-12
find . -type d -not \( -name .svn -prune \) -exec svn propset svn:ignore '*' {} \;
2010-08-15 03:45:57
User: tristan_ph
Functions: find

If you would like to ignore a directory including its subdirectory. For example, a tmp/ directory

grep -i '[^script$]' 1.txt
mencoder -idx a.ogg -ovc lavc -oac mp3lame -o b.avi
find $(echo "$PATH" | tr ':' ' ') -name "*program*"
jpegtran -optimize -outfile temp.jpg <JPEG> && mv temp.jpg "$_"
2011-07-24 08:55:46
User: h3xx
Functions: mv
Tags: jpeg

You can also save EXIF information by copying it to temp.jpg:

jpegtran -optimize -outfile temp.jpg <JPEG> && jhead -te temp.jpg "$_" && mv temp.jpg "$_"
sudo svn co svn+ ciccio_diverso://[email protected]/svn-repo/progettino
2012-02-03 18:16:02
User: 0disse0
Functions: sudo
Tags: subversion

first need to Edit the configuration file


and under the [tunnels] add this line

ciccio_diverso = /usr/bin/ssh -p 12345

adb shell ps | grep my.app.packagename | awk '{print $2}' | xargs -I ? sh -c "adb logcat -v time | grep ?"
export PROMPT_COMMAND=$PROMPT_COMMAND'; export PWD_UPCASE="${PWD^^}"'; export PS1='C:${PWD_UPCASE//\\//\\\\}>'
2012-04-30 20:09:49
User: chungy
Functions: export

(This may be specific to bash only.) This transforms the current working directory to all uppercase characters and replaces forward slashes with backslashes, prepending the string with "C:" and appending a single ">". It serves no practical purpose, but may serve as a great practical joke if you can insert it to some victim's .bashrc :-)

ps auxww | grep application | grep processtobekilled | gawk '{print $2}' | grep -v grep | xargs kill -9
2012-07-03 20:37:56
User: j0sh10
Functions: gawk grep kill ps xargs

You can also use gawk:

ps auxww | gawk '/application/' | gawk '/processtobekilled/' | gawk '{print $2}' | grep -v grep | xargs kill -9

ssh <remoteuser>@<remoteserver> \ 'mysqldump -u <user> -p<password> <database>' \ | mysql -u <user> -p<password> <database>
2013-03-05 19:20:52
User: kvcrawford
Functions: ssh
Tags: mysql ssh sync

There must be no space between -p and the password

wmctrl -r :ACTIVE: -b add,maximized_vert; wmctrl -r :ACTIVE: -b add,maximized_horz
2013-04-24 16:59:04
User: paulera

Bind it to a shortcut key, using something like xbindkeys-config (if you do not have xbindkeys: apt-get install xbindkeys xbindkeys-config)

for dir in ~/git/*; do (cd "$dir" && git pull); done
echo '#! /usr/bin/ksh\ncat $2 | openssl dgst -sha256 | read hashish; if [[ $hashish = $1 ]]; then echo $2: OK; else echo $2: FAILED; fi;' > shacheck; chmod +x shacheck; cat hashishes.sha256 | xargs -n 2 ./shacheck;
2013-09-18 21:51:20
User: RAKK
Functions: cat chmod echo read xargs

This command is used to verify a sha256sum-formatted file hash list on IBM AIX or any other UNIX-like OS that has openssl but doesn't have sha256sum by default. Steps:

1: Save to the filesystem a script that:

A: Receives as arguments the two parts of one line of a sha256sum listing

B: Feeds a file into openssl on SHA256 standard input hash calculation mode, and saves the result

C: Compares the calculated hash against the one received as argument

D: Outputs the result in a sha256sum-like format

2: Make the script runnable

3: Feed the sha256sum listing to xargs, running the aforementioned script and passing 2 arguments at a time

ffmpeg -i input.ogv -qscale 0 output.wmv # convert .ogv to .wmv
2014-06-24 16:23:18
User: mpb

I needed to convert a screen capture when using Gnome's "recordmydesktop" and convert it to a .wmv for playback in Windows.

H="--header"; wget $H="Accept-Language: en-us,en;q=0.5" $H="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" $H="Connection: keep-alive" -U "Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2" --referer=urlhere