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,363 results
find . -iname '*.mp3' | while read song; do mpg321 ${song} -w - | oggenc -q 9 -o ${song%.mp3}.ogg -; done
2010-03-14 11:34:35
User: renich
Functions: find mpg321 read
Tags: ogg mpg321

This is not recommended... lossy -> lossy = lossier.

Still, you can do it! ;)

(trap 'true' ERR; exec <SEGFAULT_PRONE_PROGRAM>)
2011-07-25 02:30:52
User: h3xx
Functions: exec trap
Tags: trap script error

Crash Override, man!

Apparently the exec call tricks BASH into setting the output buffer size to 0 under the assumption that the system (or the calling shell) will handle the output buffering. trapping the ERR signal will stop the subshell from dying and sending the ERR signal to the main script--which will terminate immediately if it does--when the program fails.

The only problem is that the kernel will output a whole bunch of stack trace garbage directly to the console device once the process segfaults, so there's no way to prevent it from being output [that I know of].

find . -iname pom.xml -type f -exec bash -c "cat {} | sed s/1\.0\.46\-SNAPSHOT/1\.0\.48\-SNAPSHOT/g > {}.tmp " \; -exec mv {}.tmp {} \;
2011-10-05 18:57:12
User: miguelbaldi
Functions: bash find mv

When a large maven release goes wrong, by deploying just some of the artifacts letting others behind, some projects got wrong SNAPSHOT versions. This command comes to help!

Tip: replace sed's regex by your version numbers

DISPLAY=":0.0" import -window root screenshot.png
2012-02-05 11:52:33
User: 0disse0
Tags: display

But if you use a screen saver, you must first disable your screen saver

kill $(ps ax | grep screensaver | grep -v grep | awk '{ print $1 }')

for a in $(cat sample.txt); do echo "${#a} $a";done|sort -n
SEED=$(head -1 /dev/urandom|od -N 1);for i in {1..10};do tmp=$(mkpasswd ${RANDOM});pass=${tmp:2:6};echo Pass $pass Crypt: $(mkpasswd $pass);done
cat *mscache* | awk -F '"' '{print $4":"$2}'
2013-01-06 06:54:57
User: mubix
Functions: awk cat

Convert Metasploit?s MSCACHE output to Hashcat version (performed in ~/.msf4/loot/):

grep -Po '^sub (\w+)' file.pm | cut -d' ' -f2
2013-03-07 12:31:34
Functions: cut grep

instead of printing the whole line, print just the capture matched, but with the "cut" pipe :( I'm so sad with grep.

emerge --moo
ls /EMRCV5/
rsync --recursive --info=progress2 <src> <dst>
2014-10-21 22:19:44
User: koter84
Functions: rsync
Tags: rsync progress

update the output of rsync after completing a file but don't create newlines, just overwrite the last line, this looks a lot better in scripts where you do want to see a progress-indicator, but not the lengthy logs

this option is available since rsync 3.1.0

using 3 thread to download some big file
touch -acm yyyymmddhhMM.ss [file]
2009-02-05 21:07:09
User: wwest4
Functions: touch

...changes modify time and access time. also:

touch -r [file1] [file2] # make file2 timestamp match file1

man fetchmail | perl -ne 'undef $/; print $1 if m/^.*?(-k \| --keep.*)-K \| --nokeep.*$/smg'
2009-06-25 23:51:35
Functions: fetchmail man perl

Using perl, here, we grep the man page of fetchmail to find the paragraph starting with '-k | --keep' and ending before the paragraph starting with '-K | --nokeep'

awk '{print substr($0, index($0,$N))}'
2009-08-31 19:47:10
User: mstoecker
Functions: awk

This command will print all fields from the given input to the end of each line, starting with the Nth field.

texmacs --delete-font-cache
2010-03-14 13:30:54
User: eastwind

after installing new fonts ( tfm , pfb , cjk , truetype ... ) manually in your ~/.Texmacs/fonts , it doesn't always reload it properly , just refresh it by delete the old cache fonts

in sample output , I just installed TrueType Chinese CJK fireflysung fonts supports

du -hs /path/to/target
bind '"\C-h": "\`fc\ \-s\`"'
2010-08-16 17:58:16
User: rthemocap

This is similar to using `!!` or

In bash 4.1 it seems you can bind directly to a shell command, but I'm not running that version.

sudo reflector -l 5 -r -o /etc/pacman.d/mirrorlist
2011-03-20 20:33:35
User: ibnarrashid
Functions: sudo

Requires 'reflector' package from official repository. '5' in the example is the number of mirrors you want in the mirrorlist, could be other numbers of course.

seq 1 1000000 | while read i; do echo -en "\r$i"; done
SUBNET="192.168.41" ; diff -y <(nmap -sP -n ${SUBNET}.0/24 | grep ${SUBNET}. | awk '{print $5}' | sort -t"." -k4 -n) <(for i in $(seq 1 254); do echo ${SUBNET}.$i; done)
2012-08-28 09:11:18
User: michel_p
Functions: awk diff echo grep seq sort

The command will make it easy to determine free IP ranges in a crowded sub-net.

machinfo | grep -i memory
2013-03-07 16:22:49
User: giorger
Functions: grep

Get the amount of physical memory in an HP-UX v11 OS when following are NOT available:

- root account

- no privileges in /proc

- no privileges in /dev/mem

for i in `pidof java`; do echo $i; ll /proc/$i; done;
2013-04-26 08:01:21
User: cuizhaohua
Functions: echo

list all java process info.

FOR /F "delims==" %%A IN ('type ips.txt') DO wmic /Node:%%A wmic /user:username /password:yourpassword /FAILFAST:ON process where "name like '%.exe'" call getowner
2014-06-26 01:53:29
User: operat0r
Tags: wmic hacking

This is used during pentest to quickly poll all the processes running on a set of systems you have common credentials for the /FAILFAST:ON speeds up the scans.

wait 536; anywait 536; anywaitd 537; anywaitp 5562 5563 5564
2014-10-22 06:31:47
User: colemar
Functions: wait


anywait () { for pid in "$@"; do while kill -0 "$pid" >/dev/null 2>&1; do sleep 0.5; done; done }

Prints dots:

anywaitd () { for pid in "$@"; do while kill -0 "$pid" >/dev/null 2>&1; do sleep 0.5; echo -n '.'; done; done }

Prints process ids:

anywaitp () { for pid in "$@"; do while kill -0 "$pid" >/dev/null 2>&1; do sleep 0.5; echo -n $pid' '; done; echo; done }

You cannot anywait for other users processes.