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,422 results
type <filename>
2009-09-14 09:37:23
User: danam
Functions: type

Also searches for aliases and shell builtins

ffmpeg -ss 0:58:15 -i DavidLettermanBlackCrowes.mpg -acodec copy DavidLettermanBlackCrowes.ac3
2009-09-14 00:08:36
User: PLA

There are some pretty good live performances on late night TV. With Mythtv I record David Letterman, Jimmy Fallon, and Conan nightly all in HD from over the air broadcasts. If I find a live performance I like I copy it to my Rockboxed iPod using this command. The Rockbox firmware knows how to downmix 5.1 audio. The command above extracts the audio from the video starting at 58 minutes and 15 seconds. It ends at the end of the file since this was the last performance of the recording. The command creates an ac3 file. I copy the ac3 file to my Rockbox iPod and rock on.

sed 's/^/$ /' "$script" | xclip
2009-09-13 11:21:54
User: intuited
Functions: sed
Tags: sed xclip meta

Assuming that $script contains the filename of a script you'd like to post as part of a comment on this site, this will prefix each line with '$' and pipe it into the X selection. From there just put the cursor in the right place in the comments box and middle-click.

Should work pretty much anywhere with xclip installed. On debian-ish systems this is installed as part of the package "xclip".

nm --dynamic <libfile.so>
2009-09-13 09:27:57
User: Vereb
Functions: nm

You can get what functions at which addresses are inside a dynamic link library by this tool.

echo foo | netcat 25
2009-09-13 01:33:02
User: pykler
Functions: echo

Using netcat, usuallly installed on debian/ubuntu.

Also to test against a sample server the following two commands may help

echo got milk? | netcat -l -p 25

python -c "import SocketServer; SocketServer.BaseRequestHandler.handle = lambda self: self.request.send('got milk?\n'); SocketServer.TCPServer(('', 25), SocketServer.BaseRequestHandler).serve_forever()"

ssh -f [email protected] DISPLAY=:0.0 smplayer movie.avi
2009-09-12 22:16:59
User: Escher
Functions: ssh

Launch a gui app remotely. In this example smplayer is installed on the remote machine, and movie.avi is in the remote user's home dir. Note that stdout/stderr is still local, so you'll have feedback locally, add '&>/dev/null' to suppress. This is surprisingly not well known (compared to running an X app locally via ssh -X). (NB. if your distro requires ~/.Xauthority file present, then try -fX if you have problems)

Resubmitted (and trimmed, thanks sitaram) due to ridiculous voting on previous submission. Fingers crossed, it gets a better rating this time.

echo "foo" > /dev/tcp/
2009-09-12 16:48:05
User: mobidyc
Functions: echo

this command will send a message to the socket 25 on host in tcp.

works on udp and icmp

understand only IP address, not hostname.

on the other side (, you can listen to this socket and test if you receive the message.

easy to diagnose a firewall problem or not.

find . \( ! -name . -prune \) \( -type f -o -type l \)
2009-09-12 15:58:56
User: mobidyc
Functions: find

you must be in the directory to analyse

report all files and links in the currect directory, not recursively.

this find command ahs been tested on hp-ux/linux/aix/solaris.

mencoder -sub subs.ssa -utf8 -subfont-text-scale 4 -oac mp3lame -lameopts cbr=128 -ovc lavc -lavcopts vcodec=mpeg4 -ffourcc xvid -o output.avi input.flv
2009-09-12 09:24:24
User: ivalladt

Gives MPEG-4/DivX output video file ready for uploading to YouTube from FLV file downloaded from the site and your own subtitle file UTF-8 encoded. No resizing needed. (?)

which <filename>
ssh [email protected]_A dd if=/dev/dvd0 > dvddump.iso
2009-09-11 18:08:36
User: kamathln
Functions: dd ssh
Tags: ssh dvd dump

You can use this to directly dump from machine A (with dvd drive) to machine B (without dvd drive) . I used this to copy dvd using my friend's machine to my netbook. Above command is to be issued on machine B.

Advantages :

1) No wasting time dumping first to machine A and then copying to Machine B.

2) You dont need to use space on Machine A. In fact, this will work even when Machine A doesnt have enough hdd space to dump the DVD.

Use -C ssh option on slow networks (enables compression).

you can replace "dd if=/dev/dvd" with any ripping command as long as it spews the iso to stdout.

for i in *;do avidemux --video-codec Xvid4 --audio-codec mp3 --load "${i}" --save "`echo "$i" | sed -e 's/\....$//'`.done.mp4" --quit; done
2009-09-11 17:07:38
User: gean01

Convert multiple files using avidemux. Version updated (thanks to the guys who helped me giving me hints about how to improve the command). Works with files whose name contains blank characters.

One of the reasons why I love open source: everyone can take something "done" and improve it to make it better! If u have suggestions, please let me know.

file /System/Library/Extensions/*.kext/Contents/MacOS/* |grep -i x86_64 |nl | tail -1 | cut -f1 -f3; file /System/Library/Extensions/*.kext/Contents/MacOS/* |grep -i "mach-o object i386" |nl | tail -1 | cut -f1 -f3
2009-09-11 16:43:27
Functions: cut file grep nl tail

Not as far off as you thought, now is it?

-mac fanboy

for L in `echo :$PATH | tr : '\n'`; do F=${L:-"."}/fileName; if [ -f ${F} -o -h ${F} ]; then echo ${F}; break; fi; done
2009-09-11 16:14:36
User: arcege
Functions: echo tr

Searches in order of the directories of $PATH. Stops after finding the entry; looks for only that fileName. Works in Bourne, Korn, Bash and Z shells.

find . -maxdepth 1 ! -name '.' -execdir du -0 -s {} + | sort -znr | gawk 'BEGIN{ORS=RS="\0";} {sub($1 "\t", ""); print $0;}' | xargs -0 du -hs
2009-09-11 16:07:39
User: ashawley
Functions: du find gawk sort xargs

A little bit smaller, faster and should handle files with special characters in the name.

diff <(ssh server01 'cd config; find . -type f -exec md5sum {} \;| sort -k 2') <(ssh server02 'cd config;find . -type f -exec md5sum {} \;| sort -k 2')
2009-09-11 15:24:59
User: arcege
Functions: diff find md5sum sort ssh

This can be much faster than downloading one or both trees to a common servers and comparing the files there. After, only those files could be copied down for deeper comparison if needed.

function nowrap { export COLS=`tput cols` ; cut -c-$COLS ; unset COLS ; }
function sepath { echo $PATH |tr ":" "\n" |sort -u |while read L ; do cd "$L" 2>/dev/null && find . \( ! -name . -prune \) \( -type f -o -type l \) 2>/dev/null |sed "[email protected]^\./@@" |egrep -i "${*}" |sed "[email protected]^@$L/@" ; done ; }
2009-09-11 15:03:22
User: mobidyc
Functions: cd echo egrep find read sed sort tr
Tags: bash ksh PATH

search argument in PATH

accept grep expressions

without args, list all binaries found in PATH

function catv { egrep -v "^$|^#" ${*} ; }
2009-09-11 14:58:47
User: mobidyc
Functions: egrep

better integration.

works on all Unices

works one bash and ksh.

sed -i 's/^/#/' FILENAME
2009-09-11 14:13:47
User: flip387
Functions: sed

With this simple sed command we can easily comment and entire file.

date -ud @$[2**31-1]
2009-09-11 08:48:50
User: Escher
Functions: date

The end of unix time and the 32bit era will be Tue Jan 19 03:14:07 UTC 2038


date -ud @$[2**31]

date: invalid date `@2147483648'


In 64bit you have much longer, at least to:

date -ud @$[2**55] Sun Jun 13 06:26:08 UTC 1141709097
sudo arp -s 00:35:cf:56:b2:2g temp && ssh [email protected]
2009-09-11 07:49:28
User: svg
Functions: arp ssh sudo

Instead of looking for the right ip address, just pick whatever address you like and set a static ip mapping.

perl -e "print scalar(gmtime(1247848584))"
2009-09-11 06:19:09
User: opexxx
Functions: perl
Tags: perl

print scalar gmtime

wget -q --spider http://server/cgi/script
2009-09-11 05:33:48
User: ashawley
Functions: wget
Tags: wget

I don't know if the --spider option works to execute a script, but it might be worth trying. Note that the Drupal project uses the following in a cron job.

wget -O - -q http://localhost/drupal/cron.php

The output is sent to standard out so it can be logged by cron.

hdiutil mount sample.iso