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



Commands by Escher from sorted by
Terminal - Commands by Escher - 14 results
while true; do xset dpms force off; sleep 0.3; xset dpms force on; xset s reset; sleep 0.3; done
2011-09-07 21:55:41
User: Escher
Functions: sleep

When aliens invade Earth, be first to warn your neighbours by placing your computer screen at a window and executing this potentially Earth-saving command.

Ctrl C when aliens are defeated.

tree -dL 1
2009-10-11 23:20:17
User: Escher

to include hidden dirs use:

tree -adL 1

(with ls, requires 'ls -ad */ .*/')

eject /dev/sdb; sleep 1; eject -t /dev/sdb
2009-10-11 23:16:49
User: Escher
Functions: eject sleep

Remounts a usb disk /dev/sdb, without having to physically remove and reinsert. (Gnome desktop)

ss -p
2009-09-19 21:55:01
User: Escher

for one line per process:

ss -p | cat

for established sockets only:

ss -p | grep STA

for just process names:

ss -p | cut -f2 -sd\"


ss -p | grep STA | cut -f2 -d\"
(sp-sc sop://broker.sopcast.com:3912/6002 3900 8900 &>/dev/null &); sleep 10; mplayer http://localhost:8900/tv.asf
2009-09-19 17:46:13
User: Escher
Functions: sleep

Get sopcast links for live sports from http://myp2p.eu (for example)

Get sp-sc or sp-auth binary by googling (sopcast + linux)

eg http://www.jbg.f2s.com/sp-sc.gz

Requires the 32bit libstdc++5 package.

After exiting mplayer, type 'killall sp-sc'

loadkeys uk
gst-launch-0.10 v4l2src ! ffmpegcolorspace ! warptv ! ffmpegcolorspace ! autovideosink
2009-09-18 18:56:35
User: Escher

in place of warptv use shagadelictv, edgetv, agingtv, dicetv, vertigotv, revtv or quarktv (see 'gst-inspect-0.10 effectv'. Requires gstreamer-plugins-good (or gstreamer0.10-plugins-good ).

For slow webcams use something like

gst-launch-0.10 v4l2src ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! warptv ! ffmpegcolorspace ! autovideosink


For basic webcam view via gstreamer use

gst-launch-0.10 v4l2src ! autovideosink
printf "%02u " {3..20}; echo
2009-09-18 18:48:41
User: Escher
Functions: printf
Tags: bash strings

emulates bash4's "echo {03..20}"

Uses bash3 builtin function printf

cvlc v4l2:// :vout-filter=transform :transform-type=vflip :v4l2-width=320 :v4l2-height=240 -f &
2009-09-16 15:30:52
User: Escher

Flips the y-axis to emulate a real mirror, uses low resolution for speed, this will also hide blemishes and the like :)

cvlc v4l2:// &
2009-09-16 14:52:36
User: Escher

Quick command to test your webcam. Press 'f' to toggle fullscreen. Can also use 'vlc v4l2://' if you want gui controls. For higher/smoother framerate lower the default resolution:

cvlc v4l2:// :v4l2-width=320 :v4l2-height=240 &
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.

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 [email protected]'


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

date -ud @$[2**55] Sun Jun 13 06:26:08 UTC 1141709097
time echo 'n=1000000;m=(n+1)/2;a=0;b=1;i=0;while(m){e[i++]=m%2;m/=2};while(i--){c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]){t=a;a+=b;b=t}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc
2009-09-10 09:00:44
User: Escher
Functions: echo time

EDIT: Trolling crap removed ;)

takes approx 6 secs on a Core 2 Duo @ 2GHz, and 15 secs on atom based netbooks!

uses monoid (a,b).(x,y)=(ax+bx+ay,ax+by) with identity (0,1), and recursion relations:



then apply fast exponentiation to (1,0)^n = (Fn,F(n-1))


Note that: (1,0)^-1=(1,-1) so (a,b).(1,0) = (a+b,a) and (a,b)/(1,0)=(a,b).(1,0)^-1=(b,a-b)

So we can also use a NAF representation to do the exponentiation,http://en.wikipedia.org/wiki/Non-adjacent_form , it's also very fast (about the same, depends on n):

time echo 'n=1000000;m=(n+1)/2;a=0;b=1;i=0;while(m>0){z=0;if(m%2)z=2-(m%4);m=(m-z)/2;e[i++]=z};while(i--){c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]>0){t=a;a+=b;b=t};if(e[i]<0){t=a;a=b;b=t-b}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc
time echo 'n=70332;m=(n+1)/2;a=0;b=1;i=0;while(m){e[i++]=m%2;m/=2};while(i--){c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]){t=a;a+=b;b=t}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc
2009-09-10 08:58:47
User: Escher
Functions: echo time

Calculates nth Fibonacci number for all n>=0, (much faster than matrix power algorithm from http://everything2.com/title/Compute+Fibonacci+numbers+FAST%2521 )

n=70332 is the biggest value at http://bigprimes.net/archive/fibonacci/ (corresponds to n=70331 there), this calculates it in less than a second, even on a netbook.

UPDATE: Now even faster! Uses recurrence relation for F(2n), see http://en.wikipedia.org/wiki/Fibonacci_number#Matrix_form

n is now adjusted to match Fn at wikipedia, so bigprimes.net table is offset by 1.

UPDATE2: Probably fastest possible now ;), uses a simple monoid operation:

uses monoid (a,b).(x,y)=(ax+bx+ay,ax+by) with identity (0,1), and recursion relations:



then apply fast exponentiation to (1,0)^n = (Fn,F(n-1))


Note that: (1,0)^-1=(1,-1) so (a,b).(1,0) = (a+b,a) and (a,b)/(1,0)=(a,b).(1,0)^-1=(b,a-b)

So we can also use a NAF representation to do the exponentiation,http://en.wikipedia.org/wiki/Non-adjacent_form , it's also very fast (about the same, depends on n):

time echo 'n=70332;m=(n+1)/2;a=0;b=1;i=0;while(m>0){z=0;if(m%2)z=2-(m%4);m=(m-z)/2;e[i++]=z};while(i--){c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]>0){t=a;a+=b;b=t};if(e[i]<0){t=a;a=b;b=t-b}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc