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,449 results
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
find . -name '*.log' | xargs ls -hlt > /tmp/logs.txt && vi /tmp/logs.txt
2009-09-17 11:47:24
User: xraj

replace @ symbol with new line character, to get new line character press Ctrl+v+enter --> ^M

egrep -v "^[[:blank:]]*($|#|//|/\*| \*|\*/)" somefile
wget -q http://dynamic.xkcd.com/comic/random/ -O-| sed -n '/<img src="http:\/\/imgs.xkcd.com\/comics/{s/.*\(http:.*\)" t.*/\1/;p}' | awk '{system ("wget -q " $1 " -O- | display -title $(basename " $1") -write /tmp/$(basename " $1")");}'
2009-12-09 13:41:25
User: laugg
Functions: awk sed wget
Tags: sed awk wget comic

Only need to install Image Magick package.

Display a xkcd comic with its title and save it in /tmp directory

If you prefer to view the newest xkcd, use this command:

wget -q http://xkcd.com/ -O-| sed -n '/<img src="http:\/\/imgs.xkcd.com\/comics/{s/.*\(http:.*\)" t.*/\1/;p}' | awk '{system ("wget -q " $1 " -O- | display -title $(basename " $1") -write /tmp/$(basename " $1")");}'
port=8888;pid=$(lsof -Pan -i tcp -i udp | grep ":$port"|tr -s " " | cut -d" " -f2); ps -Afe|grep "$pid"|grep --invert-match grep | sed "s/^\([^ ]*[ ]*\)\{7\}\(.*\)$/\2/g"
2010-01-11 17:49:22
User: glaudiston
Functions: cut grep ps sed tr

A way not so simple but functional for print the command for the process that's listening a specific port.

I got the pid from lsof because I think it's more portable but can be used netstat

netstat -tlnp
/usr/bin/links --source http://weather.noaa.gov/pub/data/forecasts/zone/md/mdz009.txt
bitpim -p $PHONE_PORT ls
2010-04-09 02:20:53
User: matthewbauer
Tags: ls list phone cdma

This will list your phone's filesystem with bitpim. (works on many LG, Samsung, and Sanyo)

See http://www.bitpim.org/help/phones-featuressupported.htm for full list.

shutdown -h $((60 * 4))
2011-05-02 07:10:10
User: retrodanny
Functions: shutdown
((60 * 4)) will be turned into 240 by bash before being input to the shutdown command, replace the 4 with whatever number of hours you want, let bash do the math.
curl -O http://www.site.com/img/image[001-175].jpg
2011-12-18 15:48:03

That command make the same that "ls -a", but just typping "la".

Tested in bash.

ssh [email protected] "ffmpeg -f x11grab -s 1920x1080 -i :0 -r 1 -t 1 -f mjpeg -" | display
2012-05-01 04:45:15
User: buhrietoe
Functions: ssh

More stealthy ffmpeg method. The imagemagick 'import' method causes a system beep.

dscacheutil ?flushcache
soft hangup Zap/1-1
2012-10-31 06:50:18
User: coolsanjiv

If a call get hanged , one can disconnect the call using the above command i.e "soft hangup . The Zap/1-1 is the name of the Channel , you wish to disconnect. There may be many channels, but you need to pick the channel name of hanged call only ...

dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
2013-01-03 21:35:19

%qdbus org.freedesktop.PowerManagement /org/kde/Solid/PowerManagement suspendToRam

Service 'org.freedesktop.PowerManagement' does not exist.

2013-03-05 22:57:14
User: fhtagn

Starts a new shell (in bash/sh, it starts bash/sh). 'man bash' explains:

"If arguments remain after option processing, and neither the -c nor the -s option has been supplied, the first argument is assumed to be the name of a file containing shell commands. If bash is invoked in this fashion, $0 is set to the name of the file, and the positional parameters are set to the remaining arguments."

dstat -d --nocolor --noheaders|xargs --max-args=2|while read status; do if [ "$status" == "0 0" ]; then setleds -L -caps < /dev/console; else setleds -L +caps < /dev/console; fi; done
2013-04-24 18:32:25
User: intangi
Functions: read setleds xargs

Some computers these days don't have an HDD activity light, but they still have a useless caps-lock, so why not re-purpose that light to show HDD activity?

Requires setleds and dstat and probably needs to run as root.

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
2013-09-19 03:25:14
Functions: echo

If the HISTTIMEFORMAT is set, the time stamp information associated with each history entry is written to the history file, marked with the history comment character.

lsof | grep -i deleted | grep REG | grep -v txt | ruby -r 'pp' -e 'STDIN.each do |v| a = v.split(/ +/); puts `:> /proc/#{a[1]}/fd/#{a[3].chop}`; end'
2014-03-11 06:02:09
User: jim80net
Functions: grep

Be careful, first run:

lsof | grep -i deleted | grep REG | grep -v txt

Then, give it the boot!

mco ping | head -n -4 | awk '{print $1}' | sort
findin() { find . -type f -name "*.$1" | xargs ack $2 }
^Z then bg
ls -A
2009-03-13 05:12:01
User: haivu
Functions: ls
Tags: terminal

This command is almost the same as 'ls -a', but it does not display the current dir (.) or parent (..)

grep -R --include=*.cpp --include=*.h --exclude=*.inl.h "string" .
2010-07-14 16:32:28
User: sweinst
Functions: grep
Tags: find xargs grep

Gnu grep allows to restrict the search to files only matching a given pattern. It also allows to exclude files.