Hide

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.
Hide

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:

Hide

News

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!
Hide

Top Tags

Hide

Functions

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

Find default gateway (proper at ppp connections too)

Terminal - Find default gateway (proper at ppp connections too)
route -n | perl -ne '$ANY="0.0.0.0"; /^$ANY/ and split /\s+/ and print "Gateway to the World: ",($_[1]!=$ANY)?$_[1]:(`ip address show $_[$#_]`=~/peer ([0-9\.]+)/ and $1),", via $_[$#_].\n"'
2011-09-13 08:05:58
User: bandie91
Functions: perl route split
2
Find default gateway (proper at ppp connections too)

Alternatives

There are 4 alternatives - vote for the best!

Terminal - Alternatives
ip route | awk '/default/{print $3}'
netstat -rn | grep UG | tr -s " " | cut -d" " -f2
ip route list 0/0
ip route show | awk '$3 ~ /^[1-9]+/ {print $3;}'
2010-08-08 23:57:23
User: kerim
Functions: awk route
-1

Find your default gateway and print it directly output.

http://www.bayner.com/

[email protected]

route -n | grep "^0\." | awk '{print "Gateway to the World: "$2", via "$NF""}'

Know a better way?

If you can do better, submit your command here.

What others think

http://cincinnatibengals.jerseyscheap.us.com

http://www.michaelkorshandbagssale.in.net

http://www.cheapnhl-jerseys.us.com

http://www.cheapmichaelkorshandbags.us.org

http://www.nikeair-huarache.me.uk

http://www.suprashoes.eu.com

http://www.truereligionjeanssale.us.com

http://chicagobulls.jerseyscheap.us.com

http://www.christian-louboutinoutlet.us

http://www.raybans-sunglasses.us.org

http://www.handbagsmichaelkors.us.org

http://www.tomsshoes.eu.com

http://www.fitflopssale-clearance.us.com

http://www.nikefree5.us.com

http://clippers.jerseyscheap.us.com

http://www.adidasnmdr1.us.com

http://www.michaelkors-outlethandbags.us.com

http://www.louisvuitton-sacpascher.fr

http://denverbroncos.jerseyscheap.us.com

http://thunder.jerseyscheap.us.com

http://www.nikeblazerlow.fr

http://www.michaelkorsoutlethandbags.us.org

http://www.michaelkorshandbags-outletonline.us.com

http://www.michael-korsoutlethandbags.us.com

http://www.fitflopssaleclearance.org

http://www.reebokoutlets.in.net

http://www.basketballshoes.us.org

http://www.michaelkors-handbagswholesale.in.net

http://dallascowboys.jerseyscheap.us.com

http://www.oakleysunglasses.nom.co

http://www.oakley.de.com

http://www.nike-tnpascher.fr

http://www.edhardyuk.me.uk

http://www.dolceandgabbana.in.net

http://www.nikeoutletstore.us.org

http://www.nikerosherunshoes.me.uk

http://www.salomon-shoes.us.com

http://www.jimmy-choo.in.net

http://celtics.jerseyscheap.us.com

http://www.kobe9elite.us

http://www.ralphlauren-pas-cher.fr

http://www.cheapmichael-korshandbags.us.com

http://www.cheapmlb-jerseys.us.com

http://chargers.jerseyscheap.us.com

http://www.rayban-sunglassescheap.us.com

http://warriors.jerseyscheap.us.com

http://www.birken-stocksandals.com

http://www.ralphlaurenoutlet.com.co

http://www.michaelkors-outletclearance.in.net

http://www.cheap-michaelkorshandbags.us.org

http://www.michael-korsoutletstore.us.org

http://neworleanssaints.jerseyscheap.us.com

http://www.instyler-max.in.net

http://www.ghd-flatiron.com

http://www.niketrainersuk.com.co

http://www.michaelkorsoutletstore.us.org

http://www.nikehuarache.org.uk

http://www.oakleysunglassescheap.us.org

http://www.edhardyoutlet.name

http://indianapoliscolts.jerseyscheap.us.com

http://www.gucciborse2016.it

http://philadelphiaeagles.jerseyscheap.us.com

http://arizonacardinals.jerseyscheap.us.com

http://newyorkjets.jerseyscheap.us.com

http://www.chaussurelouboutinpas-cher.fr

http://www.skechers-outlet.us

http://www.tiffanyandco-outlet.us

http://www.jordanshoes.eu.com

http://miamiheat.jerseyscheap.us.com

http://www.versace-shoes.in.net

http://chicagobears.jerseyscheap.us.com

http://miamidolphins.jerseyscheap.us.com

http://clevelandbrowns.jerseyscheap.us.com

http://www.michaelkorshandbagswholesale.in.net

http://oaklandraiders.jerseyscheap.us.com

http://www.hugobosssale.name

http://www.pandora-jewelryoutlet.name

http://kansascitychiefs.jerseyscheap.us.com

http://www.michaelkors-handbagsoutlet.in.net

http://www.michaelkorshandbagscheap.in.net

http://www.asics-runningshoes.in.net

http://www.michaelkorsuk.org.uk

http://www.ferragamo-shoes.cc

http://www.underarmouroutlet.cc

http://atlantafalcons.jerseyscheap.us.com

http://www.eccoshoesoutlet.us

http://jaguars.jerseyscheap.us.com

http://buffalobills.jerseyscheap.us.com

http://tennesseetitans.jerseyscheap.us.com

http://greenbaypackers.jerseyscheap.us.com

http://www.the-northface.co.uk

http://www.cheapnbajerseys.us.com

http://newyorkgiants.jerseyscheap.us.com

http://pittsburghsteelers.jerseyscheap.us.com

http://sanfrancisco49ers.jerseyscheap.us.com

http://carolinapanthers.jerseyscheap.us.com

http://www.cheap-nikeshoes.org

http://lakers.jerseyscheap.us.com

http://www.poloralph-lauren.com.co

http://baltimoreravens.jerseyscheap.us.com

http://www.nikeairhuarache.com.co

http://www.michael-korsoutletonline.us.org

http://www.jordan-shoes.us.org

http://www.outletmichaelkors.us.org

http://houstontexans.jerseyscheap.us.com

http://www.michaelkorshandbagswholesale.us.com

http://newenglandpatriots.jerseyscheap.us.com

http://www.handbagsmichaelkors.us.com

http://minnesotavikings.jerseyscheap.us.com

http://www.yeezyboost-350.us.org

http://www.omega-watches.name

http://www.michaelkorshandbagswholesale.us.org

http://www.michaelkors-handbagswholesale.us.com

http://www.michaelkorshandbagssale.us.com

http://cavaliers.jerseyscheap.us.com

http://www.pandoracharms.me.uk

http://www.abercrombieandfitchkids.us.com

http://www.nikeblazerpascher.fr

http://www.saclongchampfr.fr

http://seattleseahawks.jerseyscheap.us.com

http://www.nikestoreuk.com.co

http://www.airforce1.us.org

http://www.michaelkorshandbags.uk

http://www.airjordanuk.org.uk

http://www.moncleroutletstore.us.org

http://www.handbagsmichaelkors.in.net

http://newyorkknicks.jerseyscheap.us.com

http://www.nike-trainers.com.co

http://www.rolexreplica-watches.com.co

http://www.michaelkorsoutlethandbags.in.net

http://sanantoniospurs.jerseyscheap.us.com

http://www.lebron-jamesshoes.net

http://www.new-balanceshoes.in.net

http://www.armaniexchangeoutlet.us

http://www.conversetrainer.org.uk

http://www.redvalentino.in.net

http://washingtonredskins.jerseyscheap.us.com

http://www.cheap-nfljerseyswholesale.us.com

http://www.nmdadidas.us.org

http://detroitlions.jerseyscheap.us.com

http://www.airmax90.eu.com

http://www.montblancpensoutlet.name

http://www.longchamps.us

Comment by xxxxxxxxxxx123 1 week and 2 days ago

Your point of view

You must be signed in to comment.