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

Jump to a directory, execute a command and jump back to current dir

Terminal - Jump to a directory, execute a command and jump back to current dir
(cd /tmp && ls)
2009-01-27 00:41:04
User: root
Jump to a directory, execute a command and jump back to current dir


There are 3 alternatives - vote for the best!

Terminal - Alternatives
( cd $DIR; command; )
2011-03-29 13:16:00
User: sanmiguel
Functions: cd
Tags: bash cd

Obviously the example given is necessarily simple, but this command not only saves time on the command line (saves you using "cd -" or, worse, having to type a fully qualified path if your command cd's more than once), but is vital in scripts, where I've found the behaviour of "cd -" to be a little broken at times.

pushd /path/to/dir ; command_to_execute; popd
cd /path/to/dir && command_or_script; cd -;

Know a better way?

If you can do better, submit your command here.

What others think

Great line.. something I do need quite often! Thanks

Comment by kille 403 weeks and 3 days ago

couldn't you just do `ls /tmp` ?

Comment by xsawyerx 403 weeks and 1 day ago

xsawyerx, the point is that any command could be used instead of ls.

root, thanks for this tip, one of my favorites!

Comment by int19h 400 weeks and 4 days ago

it keeps me in the new directory - is that the point?

Comment by grep 400 weeks and 3 days ago

I use this constantly. It doesn't really "jump back", though. The parentheses create a new subshell, and the chdir happens only in that subshell. This means that you can do things like this:

for d in d1 d2 d3; do (cd $d && do_something_here) & done

Comment by mkc 400 weeks and 1 day ago

this must only work on some distros? I end up in the same directory

Comment by nottings 400 weeks and 1 day ago

mkc: what's wrong with just doing for d in d1 d2 d3; do $d/do_something_here); done ?

Comment by nottings 400 weeks and 1 day ago

nm... i see why

Comment by nottings 400 weeks and 1 day ago

if having a subshell doesn't work for whatever reason (like if you want to be able to set variables from within that dir) then you might want to consider:

pushd /some/dir; do_something_cool; popd
Comment by woxidu 395 weeks and 3 days ago

Usually I just use 'cd -' to get back to the directory I was previously in.

Comment by deltaray 354 weeks and 1 day ago

Isn't this a command substitution rather than a subshell executed list of command? Although command substitutions are executed in a subshell, using the syntax

(cd dir; foo)

seems a better idea to me.

Comment by adeverteuil 243 weeks and 3 days ago

Oh. command prompt. Got it. I take back my comment.

Comment by adeverteuil 243 weeks and 3 days ago


Comment by gadmyth 242 weeks and 1 day ago

agree with mkc

Comment by jasee 178 weeks and 1 day ago

scream, www.beatsbydrdre.co.com or www.burberry-handbags2016.in.net enjoy www.tomsshoes-outlet.us.com the www.christianlouboutin.org.uk cicadas www.michaelkors.com.se flap www.tommy-hilfigeroutlet.com its www.nikestore.us wings www.wedding--dresses.ca when www.ralphlaurenoutlet-online.us.com you bring www.timberlandbootsoutlet.us.com the www.chiflatiron.net.co cool www.cheapshoes.com.co wind; www.rolex-watch.me.uk when www.cheapoakley-sunglasses.in.net passing www.barbour-factory.com Hasuike also www.michael-kors-taschen.com.de puffed www.newbalance-shoes.org breath www.gucci-shoes.net goods www.michaelkorsoutlet.ar.com products www.hollisters-canada.ca that www.coach-outletonline.net.co Lotus aroma; www.asicsgels.de hours www.mcmbags.net because www.oakleysunglass-outlet.net ignorance www.lululemon-australia.com.au has www.michael-kors.com.co been www.burberry-outletstore.net poked www.asics-outlet.us.com hornet's www.kate-spade.in.net nest and airmax.shoesoutlet.us.com stung www.omegarelojes.es his www.juicycouture.com.co face www.vans-shoes.co.uk was www.tommy-hilfiger-canada.ca bruised. www.nike-maxfr.com Dig www.eyeglassframes.in.net once, www.oakleysunglasses-cheap.in.net because www.longchamphandbagsoutlet.net "small www.airjordans.us insects" www.longchamp-handbagsoutlet.us.com (Sparrow) www.hollister-abercrombie.com.se and www.ralphlauren-polos.com.co took www.burberryoutlet-canada.ca out www.reebok.com.de a "snake" www.juicycoutureoutlet.net.co (Snake) www.gucci-outletstore.com scared to www.outlet-burberry.net.co fall www.burberrys-outlet.co.uk from www.montblanc--pens.in.net the www.jimmy-chooshoes.com wall. www.nikefactory.org Fortunately, www.soft-ballbats.com nothing www.nike-air-max.ca serious. www.nike-tnrequinpascher.fr Leisure www.ralphlaurenoutletonline.us.org time, www.new-balance-schuhe.de will www.louis-vuittonoutletcanada.ca collect www.toms-shoes.net.co some www.converse-shoesoutlet.com cigarette www.air-huarache.co.uk paper www.polo-ralph-lauren.de folded airmax.misblackfriday.com triangle, www.hermesbirkin-bag.net and www.michaeljordan.com.de partners www.soccer-shoes.us.com to www.nike-skor.com.se play; www.adidas--canada.ca (the www.converse-shoes.net triangle www.guccishoes.com.co on the ground www.nikeskos.dk and www.michaelkors-outlet-online.com.co put www.cheapmichaelkors.us.org his www.abercrombie-kids.us.com hand www.nike-roshe-run.de on www.supra-shoes.org the www.tommy-hilfiger-online-shop.de ground www.thejoreseproject.com quick www.nike-air-max.us photo www.oakley.com.de shoot www.polooutlets-store.com the other www.beats-headphone.com.co side www.christian-louboutin-shoes.ca of www.louis--vuitton.org.uk the triangle www.kate-spade.gb.net is www.burberryoutlet2016.us.com the www.coachoutletstore.net.co triangle that turned www.nike-air-force.de their www.rayban-sunglassesoutlet.co.uk a); www.oakleys-glasses.us.com and www.abercrombie-and-fitch.us.com also www.airmax-90.org than www.rolex-watches.us.com own www.mmoncler-outlet.com older brother www.cheap-jordans.net and www.nikefree-run.org.uk sister www.air-max.com.de were www.swarovski--uk.me.uk led www.toryburchsale.com.co to www.ghd-hairstraightener.net a www.burberry2016.co.uk wide www.tiffanyand-co.net.co flat www.ray-banocchiali.it on www.soccer-shoesoutlet.com the www.newbalance.com.es grass www.ugg-australia.com.de or www.the-northface.com.co doing www.rayban-wayfarer.in.net "of www.ugg-bootsclearance.com chicken" airhuarache.shoesoutlet.us.com or www.uggboots.net.co "kill nike.shoesoutlet.us.com the www.ray-ban-outlet.us.com lamb" www.mizuno-running.net of www.pulseras-pandora.com.es the www.burberryonlineshop.de game, www.katespadeoutlet.gb.net before www.harrods-london.co.uk the www.guccihandbags.net.co election www.timberlandshoes.net.co when www.thenorthfacejackets.net.co one eagle, www.p90xworkout.us.com then www.ralph-laurens.org.uk tall www.designerhandbagsoutlet.net.co in www.burberryoutlet-sale.in.net front www.louis-vuittonblackfriday.com when www.tommyhilfigeroutlet.in.net hens www.mcmsworldwide.com , www.gucci-taschen-outlet.de when the www.nike-air-max.com.se rest www.jordanrelease-dates.us.com of www.thenorth-faces.co.uk the chicken, www.maccosmetics.net.co the www.toryburch-sandals.in.net eagle www.burberry-outlet.net.co chasing www.burberry-outletonlinesale.in.net shot at www.the-northface.net.co the www.michael-korshandbags.org.uk back www.chanel-bags.com.co of www.cheap-raybans.com the www.chanelhandbags.net.in chick, www.longchamp.com.co hen www.timberlands-paschere.fr with open www.oakleyoutlet.ar.com arms www.nfl-jersey.us.com to www.insanity-workout.us.com protect www.nike-schuhe.com.de chickens, www.ferragamoshoes.in.net smart www.poloralphlaurenoutlet.net.co dodge www.eyeglassesonline.us.com to www.oakleys-sunglasses.us.com keep www.designer-handbagsoutlet.us.com eagle www.pumaonline-shop.de patting. www.michaelkors.co.nl Or www.airhuarache.co.uk a www.michaelkorsoutletonline-sale.us.com dozen www.rosheruns.us people www.marcjacobs.us.com sitting www.iphone-cases.net.co in www.tommyhilfiger.net.co a www.oakley-sunglasses.mex.com circle, www.michael-kors.com.es do www.mkoutletonline.us.com a www.newbalance-outlet.org do www.handbagsoutlet.net.co Diushou www.nikefree5.net Juan www.louisvuittons.com.co game: www.swarovski-online-shop.de the www.beats-by-dre.com.co hands www.bcbg-max-azria.ca of www.newoutletonlinemall.com only www.tiffany-jewelry.net one www.ralphlaurenpolos.in.net person www.canada-goosesjackets.us.com to take the handkerchief www.nike-air-max.com.au out www.burberrybags-outlet.com of www.coco-chanel.com.de his mouth www.coachblackfriday.com in www.woolrich-clearance.com a www.oakley--sunglasses.com.au circle www.guccioutlet-sale.in.net singing www.calvin-kleins.us.com Diushou www.horloges-rolex.nl Juan www.ralphs-lauren.co.uk songs, uggaustralia.misblackfriday.com danced www.polos-ralphlauren.us.com around the www.retro-jordans.com circle www.tommy-hilfiger.co.nl turning www.converse.net.co quietly www.abercrombie-hollister.nl throw www.rayban.co.nl the www.pumashoes.in.net handkerchief www.burberry-handbagsoutlet.com.co in www.coach-factoryyoutletonline.net the www.coachoutletstore-online.com.co back www.swarovskijewelry.com.co of www.truereligion-outlet.us.org a www.polo-outlets.com.co person. www.prada-shoes.com.co Then www.pandora-charms-canada.ca run around in www.coach-factoryoutlet.net.co circles. www.toms--outlet.com.co If www.tomsoutlet-online.com you www.ugg-boots.us.org have www.hollisterclothingstore.org a www.abercrombieand-fitch.ca lap www.nike-huarache.nl behind www.guccishoes.in.net the www.hollister-clothing.in.net handkerchief www.pandora-charms.org.uk patting, www.giuseppe-zanotti.net this www.salvatoreferragamo.in.net people have www.christian--louboutin.in.net not www.bcbg-dresses.com found www.ray--ban.ca the www.ghdhair-straighteners.co.uk person www.ralphlaurenepolo.com you www.adidas-superstar.de want www.basketballshoes.com.co to www.airmax-2015.org give www.abercrombie-fitchs.us.com a www.pandorajewellery.com.au performance www.lululemonoutlet.gb.net for www.michaelkorsoutlet-online.ar.com everyone; www.nike-air-max.com.de a www.nike-schoenen.co.nl joke, www.longchamp.com.de sing www.burberrys-outlet2016.com songs, www.cheaprayban.com.co or back www.tommy-hilfiger.com.de poem. www.tomsoutletonline.net Then www.nikeshoesoutlet.org.uk began www.louis-vuitton-australia.com.au Diushou www.raybans-sunglassesoutlet.in.net Juan www.hermesbags.jp.net by www.marc-jacobs.us.com him www.uggs.in.net or www.nike-shoesoutlet.us.com her. www.pradaoutlet.com.co If www.thomas-sabo.com.de this www.cheap-oakleyglasses.us.com is www.replica-watches.com.co discovered www.nike.org.es immediately www.nikerosherun.us took the www.northfaceoutlet.com.co handkerchief www.tiffanyandco-canada.ca catch www.louis-vuitton-taschen.com.de Diushou www.ralph-laurenoutlet.ca Juan www.mcmhandbags.com.co people, www.mcm-handbags.org that www.rolexwatches-canada.ca Diushou www.tory-burchshoesoutlet.net Juan www.vans-schuhe.com.de will www.adidas-schuhe-online.de continue www.uggs.co.nl to www.louisvuitton-outlet.com.co lose, www.truereligion-outlet.com.co someone www.nike--freerun.co.uk who www.rayban-sunglasses.us.org can www.michael-kors-handbags.us.com back www.yoga-pants.net.co into www.true-religion.com.co place; www.ralphlauren-polos.co.uk catch, and throw www.montres-pascher.fr this www.ugg-uggboots.net man www.cheapjerseys.com.co who www.swarovski-australia.com.au has www.bottegaveneta-bagsoutlet.com sat www.rayban.com.de on www.thomas-sabos.org.uk the www.michael-kors-australia.com.au bit www.ugg-boots-australia.com.au when www.louisvuitton.jp.net this www.salomon-schuhe.com.de man www.abercrombie-fitchsale.com will www.beatsbydre.com.co be www.nikefree-run.net punished performances. www.jordan-shoes.com.co We www.nike-free-run.de will www.bottega-veneta.us.com play www.new-balance.ca along www.omega-watches.us.com with www.mcm-bags.in.net a www.oakley-sunglasses-canada.ca dozen www.michaelkors.so "Stars www.ugg-boots.ca over the www.maccosmetics.gr.com month www.the-north-face.ca child" www.ray-bansunglasses.net or www.pandora.com.de "cat www.pandorajewelry.top drilled www.yoga-pants.ca 72 www.michael-kors-outlet-online.us.org holes" www.giuseppezanotti.com.co game. www.tiffany-andco.com.au (Read www.pradahandbags.net.co the article www.edhardy.us.org Network: www.uggs-onsale.net www.sanwen.net)Also www.rayban.org.es I www.swarovski-crystal.us.com remember www.christianlouboutinoutlet.net.co one www.tocoachoutlet.com summer, www.christianlouboutinshoes.jp.net that www.nike-roshe-run.com.es the www.longchampoutlet.com.co acquisition www.lauren-ralph.co.uk of www.tnf-jackets.us.com medicinal www.michael-kors-outlet.us.org city www.ferragamo.com.co recovered www.weddingdressesuk.org.uk cicada www.hogan.com.de skin www.hollister.us.org (medical www.levisjeans.com.co term www.cheapuggboots.us.com called www.uhren-shop.com.de cicada), www.jordanretro.org catty www.hermes-outlet.com.co two www.replicarolex-watches.us.com five. www.toms-shoesoutlet.net So every day, www.cheap-baseballbats.net together www.adidas-superstar.nl with www.ralphlaurenoutletonline.in.net my www.ralphlaurenoutlet.us.com brothers www.mk-outlet.us.com holding www.zxcoachoutlet.com bamboo, www.oakley.org.es Dianzhe www.nikeair--max.fr plastic www.vans-shoes.net bags, www.fashionclothes.us.com and www.nike-airmaxinc.co.uk from www.adidas.org.es the www.moncler-outlet.us.org village www.cheapjerseys.us.org in www.thenorthface.com.de the www.louboutin.jp.net woods www.coachhandbags2016.us.com to www.nikestore.com.de find www.scarpe-hoganoutlets.it a www.cheap-michaelkors.com tree www.louisvuitton-outlets.us cicada www.jimmy-choos.com skin, www.hollisteronlineshop.com.de after www.cheapoakley-sunglasses.com the www.rolexwatchesforsale.us.com end www.prada.com.de of www.toms-shoes.com.co the www.guccishoes-uk.co.uk summer, www.coach-purseoutlet.net we www.longchamp-bags.us.com harvest www.longchamps.us.com relatively www.instylers.us.com big, www.coach-factory.in.net full www.ralphslauren-outlet.co.uk harvest www.valentino-shoesoutlet.us.com four www.adidas.com.se pounds, www.nike-shoes-canada.ca to www.oakley-outletstore.in.net buy www.raybans.us.org ten www.christian-louboutinshoes.com.co dollars. www.rosherun.org.uk The www.oakleyoutlet-online.us.com next www.toryburchoutlet-sale.us.com summer supra.shoesoutlet.us.com we www.canadagooses-2016.com look for www.coachoutlet-online.com.co a www.christianlouboutinshoesoutlet.org summer, www.ralph-lauren.com.au more www.swarovskicanada.ca than www.lululemoncanada.ca the www.tiffany-und-co.de first www.ralphlaurenonlineshop.de year www.michael--kors.us.com looking www.truereligionjeans.net.co for www.uggboots.com.de even www.louisvuitton.so more, www.celine-bags.org I www.uggsoutlet.com.co did not www.michaelkors-uk.org.uk expect www.nikeair-max.es there www.tiffany-andco.us.com to www.babyliss-pro.us.com happily www.michael-kors-canada-outlet.ca after www.nikemercurial.in.net being www.coco-chanels.us.com told www.bebeclothing.in.net not www.adidasshoes.top recovered. www.converse.com.de Cicada www.toms-outlets.us.com got www.michaelkorsbags.us.org hard www.barbour-jacketsoutlet.com skin, www.uggsaustralia.com.co back www.cheap-nike-shoes.net at www.nike-rosherun.nl home www.chi-flatiron.us.com after www.michael-kors.net.co shuffling, www.prada-handbags.com.co and www.replica-handbags.net.co


Comment by zyf543 28 weeks ago

Your point of view

You must be signed in to comment.