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,420 results
cd !$
readom dev=/dev/scd0 f=/path/to/image.iso
2009-03-08 13:21:23
User: atoponce

Many like to use 'dd' for creating CD/DVD iso images. This is bad. Very bad. The reason this is, is 'dd' doesn't have any built-in error checking. So, you don't know if you got all the bits or not. As such, it is not the right tool for the job. Instead, 'reaom' (read optical media) from the wodim package is what you should be using. It has built-in error checking. Similarly, if you want to burn your newly creating ISO, stay away from 'dd', and use:

wodim -v -eject /path/to/image.iso
find /dir_name -mtime +5 -exec rm {} \
2009-03-08 12:03:44
User: eleffie
Functions: find rm
Tags: delete

This command will delete files i a given path (/dir_name) , which older than given time in days (-mtime +5 will delete files older than five days.

perl -0777 -ne 'print "$1\n" while /word-a(.*?)word-b/gs' filename.txt
2009-03-08 11:47:18
User: eleffie
Functions: perl

This command will display all lines between 2 patterns: word-a and word-b

useful for grepping command outputs from file

find . -type f -iname '*.wmf' | while read FILE; do FILENAME="${FILE%.*}"; wmf2svg -o ${FILENAME}.svg $FILE; done
2009-03-07 22:21:01
User: atoponce
Functions: find read

This assumes you have the package installed necessary for converting WMF files. On my Ubuntu box, this is libwmf-bin. I used this command, as libwmf is not on my wife's iMac, so I archived the directories containing the WMF files from OS X, ran them on my Ubuntu box, archived the resulting SVGs, and sent them back to her. Quick, simple and to the point.

Searches directories recursively looking for extensions ignoring case. This is much more readable and clean than -exec for find. The while loop also gives further flexibility on complex logic. Also, although there is 'wmf2svg --auto', it expects lowercase extensions, and not uppercase. Because I want to ignore case, I need to use the -o option instead.

Works in ZSH and BASH. Haven't tested in other shells.

cuebreakpoints "$2" | shnsplit -o flac "$1"
2009-03-07 21:04:45
User: photraip

Converts a single FLAC file with associated cue file into multiple FLAC files.

Takes two arguments: the name of the FLAC file and and the name of the cue file.

Example: flacAlbumToFiles foo.flac foo.cue


- cuetools

- shntools

ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed "/^ 0.0 /d"
echo "The date is: $(date +%D)"
2009-03-07 15:51:59
User: atoponce
Functions: echo

This is a simple example of using proper command nesting using $() over ``. There are a number of advantages of $() over backticks. First, they can be easily nested without escapes:

program1 $(program2 $(program3 $(program4)))


program1 `program2 \`program3 \`program4\`\``

Second, they're easier to read, then trying to decipher the difference between the backtick and the singlequote: `'. The only drawback $() suffers from is lack of total portability. If your script must be portable to the archaic Bourne shell, or old versions of the C-shell or Korn shell, then backticks are appropriate, otherwise, we should all get into the habit of $(). Your future script maintainers will thank you for producing cleaner code.

nmap -sP -T Insane
cat <( command1 arg arg ) <( command2 arg ) ...
2009-03-07 04:33:12
User: Pistos
Functions: cat

Concatenate the stdout of multiple commands.

ls -1 *.part1.rar | xargs -d '\n' -L 1 unrar e
find /usr/lib -maxdepth 1 -type l -print0 | xargs -r0 du -Lh
2009-03-07 00:17:45
User: starchox
Functions: du find xargs

You also can sum the file usage of all files

find /usr/lib -maxdepth 1 -type l -print0 | xargs -r0 du -Lch
INFILE=/path/to/your/backup.img; MOUNTPT=/mnt/foo; PARTITION=1; mount "$INFILE" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "$INFILE" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ]

Suppose you made a backup of your hard disk with dd:

dd if=/dev/sda of=/mnt/disk/backup.img

This command enables you to mount a partition from inside this image, so you can access your files directly.

Substitute PARTITION=1 with the number of the partition you want to mount (returned from sfdisk -d yourfile.img).

ttmkfdir mkfontdir fc-cache /usr/share/fonts/miscttf
2009-03-06 21:28:17
User: starchox
Functions: fc-cache

First you have to create a directory in your system, where the fonts will be stored, and copy them.

sudo mkdir /usr/share/fonts/miscttf; sudo cp *.ttf /usr/share/fonts/miscttf

After recharge cache with the command

ps -o %mem= -C firefox-bin | sed -s 's/\..*/%/'
for x in `find /path/ -type d | cut -b bytesoffoldername-`; do mkdir -p newpath/$x; done
ls -ltcrh
tcptraceroute www.google.com
some_cronjobed_script.sh 2>&1 | tee -a output.log | grep -C 1000 ERROR
2009-03-06 17:51:13
User: DEinspanjer
Functions: grep tee
Tags: Linux

The large context number (-C 1000) is a bit of a hack, but in most of my use cases, it makes sure I'll see the whole log output.

cat $(ls -tr | tail -1) | awk '{ a[$1] += 1; } END { for(i in a) printf("%d, %s\n", a[i], i ); }' | sort -n | tail -25
2009-03-06 17:50:29
User: oremj
Functions: awk cat ls sort tail

This command is much quicker than the alternative of "sort | uniq -c | sort -n".

du -sh *
tail -f *[!.1][!.gz]
2009-03-06 16:24:44
User: piscue
Functions: tail

with discard wilcards in bash you can "tail" newer logs files to see what happen, any error, info, warn...

hdiutil makehybrid -udf -udf-volume-name DVD_NAME -o MY_DVD.iso /path/
2009-03-06 15:45:59
User: occam
Tags: Os X macosx

/path/ is the root folder of the DVD, not the VIDEO_TS folder.