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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.
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

Generate random valid mac addresses

Terminal - Generate random valid mac addresses
ruby -e 'puts (1..6).map{"%0.2X"%rand(256)}.join(":")'
2010-12-08 10:01:31
User: eightmillion
3
Generate random valid mac addresses

Ruby version.

Also, a perl version:

perl -e 'printf("%.2x.",rand(255))for(1..5);printf("%.2x\n",rand(255))'

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives
for i in {0..1200}; do for i in {1..12} ; do echo -n ${hexchars:$(( $RANDOM % 16 )):1} ; done | sed -e 's/\(..\)/:\1/g' | sed 's/.\(.*\)/\1/' ; echo; done
2010-12-04 16:44:11
User: Raymii
Functions: echo sed
2

First set the variable $hexchars:

hexchars="0123456789ABCDEF"

Change the number in the first for loop if you need less then 1200 mac addresses

h=0123456789ABCDEF;for c in {1..12};do echo -n ${h:$(($RANDOM%16)):1};if [[ $((c%2)) = 0 && $c != 12 ]];then echo -n :;fi;done;echo
2010-12-05 01:35:03
User: dabom
Functions: echo
Tags: Network bash mac
2

Doubt it actually generates valid mac addresses but this version doesn't need any external commands so it runs much faster.

Much shorter as well.

for i in {1..6}; do printf "%0.2X:" $[ $RANDOM % 0x100 ]; done | sed 's/:$/\n/'
2010-12-07 19:26:58
User: forcefsck
Functions: printf sed
Tags: Network bash mac
2

Shorter and more straightforward.

Also in perl:

perl -e 'print join(":", map { sprintf "%0.2X",rand(256) }(1..6))."\n"'
python -c "from itertools import imap; from random import randint; print ':'.join(['%02x'%x for x in imap(lambda x:randint(0,255), range(6))])"
macchanger -A (nic)
2010-12-07 20:22:54
User: pebkac
Tags: Network bash mac
0

You have to install the package macchanger but this command will create a random mac from a list of known manufacturers. If you want to make a complete random mac, use the -r option .

Know a better way?

If you can do better, submit your command here.

What others think

Perl should match ruby style

perl -e 'print join(":", map { sprintf "%0.2X",rand(255)}(1..6))."\n"'
Comment by forcefsck 354 weeks ago

http://www.generaliopen.at

http://www.columbiaoutlet-store.com

http://www.coachfactory-outletstoreonline.us.com

http://www.coach--purses.in.net

http://www.coachoutletonlinesales.us.com

http://www.ralphlaurenoutlet.nom.co

http://www.coachoutlet-storeonline.us.org

http://www.louisvuittonoutlettrade.us.com

http://www.energimamerking.no/ugg.html

http://www.chelseajersey.org.uk

http://www.recoilmag.com.au/ralph-lauren.html

http://www.adidasyeezyboost350v2.in.net

http://www.nikehuarache.me.uk

http://www.kate-spadeoutletonline.us

http://www.lecoqsportifchaussures.fr

http://www.oakley-sunglassesonsale.us.com

http://www.nikerunning.org.uk

http://www.fitflops.us.org

http://www.adidas-ultraboost.com

http://www.raybanpascher.fr

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

http://www.michaelkorsonlineoutlet.us.org

http://www.adidastrainers.uk

http://www.ralphlaurenuk.uk

http://www.ralphlaurenpolo.in.net

http://www.fitflops.org

http://www.oakleys.com.co

http://www.energimamerking.no/michael-kors.html

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

http://www.nfl-jerseys.in.net

http://www.michaelkorshandbagsuk.uk

http://www.nikecortez.org

http://www.christianlouboutinoutletusa.us.com

http://www.adidasstansmith.org.uk

http://www.sunglassesoakley.com.co

http://www.adidasfootballboots.me.uk

http://www.coachoutletfactoryonline.us.org

http://www.buymichaelkorshandbags.us.com

http://www.rdsk.ch

http://www.nikefootballboots.org.uk

http://www.cheapraybans.ca

http://www.thenorthfaceoutletjackets.us.com

http://www.jpgconseil.fr

http://www.adidas.in.net

http://www.ray-bansunglassesoutlets.us.com

http://www.ray-banssunglasses.me.uk

http://www.michael-kors-handbags.us.org

http://www.poloralphlaurenoutletonilne.us.com

http://www.toryburchsale.us.com

http://www.michaelkorsoutletonlinesales.us.com

http://www.giuseppe-zanotti.us.com

http://www.coachoutletstoreonlineofficial.us.com

http://www.oakleysunglassess.com.co

http://www.nikeblazers.in.net

http://www.toryburchoutletsonline.us.com

http://www.oakleyssunglasseswholesale.us.com

http://www.louis-vuittonoutletus.us.com

http://www.coachwallets.us.com

http://www.louboutinparis.fr

http://www.poloralphlaurenonlineoutlet.us.com

http://www.michaelkorsoutletfactoryonline.us.com

http://www.michaelkorsbagsuk.co.uk

http://www.adidas-nmd.co.uk

http://www.adidasshoes.in.net

http://www.truereligion-jeans.com.co

http://www.louboutinoutlets.us.com

http://www.proglas.at

http://www.fitflops.us.com

http://www.oakleys-sunglassesoutlet.us.com

http://www.poloralphlauren-outlet.in.net

http://www.pandorajewelryuk.org.uk

http://www.macysmichaelkorshandbags.us.com

http://www.polooutletstores.in.net

http://www.sevensoulmotion.be

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

http://www.burberryonlineoutlet.net.co

http://www.nike-airmax.me.uk

http://www.edhardyclothing.in.net

http://www.calvinklein.co.com

http://www.columbiasportswear.in.net

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

http://www.dardanet.se/Ralph lauren.html

http://www.wholesale-nfljerseys.us.com

http://www.montblanc.com.co

http://www.fitflopssaleclearance.us.org

http://www.coachoutletfactoryoutlet.us.com

http://www.adidaszxflux.org.uk

http://www.true-religion.me.uk

http://www.rayban-sunglasses.com.co

http://www.birkenstocksandals.org

http://www.adidasoutletclearance.com

http://www.grnet.ch

http://www.vibramfivefingers.in.net

http://www.outletpolo-ralphlauren.us.com

http://www.ferragamooutlet.us.com

http://www.stansmithadidas.us.com

http://www.ralphlaurenoutletonilne.us.com

http://www.vansshoesoutlet-store.com

http://www.lebron13shoes.com

http://www.tretronik.se

http://www.oakleysunglasses-outlet.com.co

http://www.outletslongchamp.us.com

http://www.fredperrypoloshirts.us.com

http://www.kobeshoes.us.com

http://www.kibbie.at

http://www.truereligion.net.co

http://www.cheap-mlb-jerseys.us.com

http://www.nikefreerun.us.com

http://www.northfacerainjacket.us.com

http://www.recoilmag.com.au/michael-kors.html

http://www.coach-factoryonline.us.org

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

http://www.truereligionsale.com.co

http://www.chaussureschristianlouboutin.fr

http://www.anzeigenmaerkte.ch

http://www.recoilmag.com.au/adidas-yeezy.html

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

http://www.underarmour.in.net

http://www.toryburchoutlet.net.co

http://www.nikeairmaxuk.me.uk

http://www.true-religionjeans.us.org

http://www.hermes.me.uk

http://www.christianlouboutinsale.org.uk

http://www.bliriknu.se

http://www.fitflopsoutlet.us.com

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

http://www.mamiundich.ch

http://www.pandora-jewelry.name

http://www.gosl.co.uk

http://www.jordanshoes.us.org

http://www.energimamerking.no/ray-ban.html

http://www.montblancpenofficial.us.com

http://www.reebokshoesoutlet.us.com

http://www.adidasyeezy-boost.us.com

http://www.oakleystore.com.co

http://www.outletcoachfactory.us.com

http://www.pandorajewelry.in.net

http://www.jordansretro.us.com

http://www.alupro.fr

http://www.longchamp-handbags.us.org

http://www.adidas-nmdshoes.us.com

http://www.cocoritosrl.it

http://www.energimamerking.no/canada-goose.html

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

http://www.niketrainers.uk

http://www.officialcoachoutletonline.us.com

http://www.outletschristianlouboutin.us.com

http://www.pradashoes-outlet.com

http://www.outletcoachs.us.com

http://www.nikeairmaxshoes.us.com

http://www.nikeoutlet-online.com

http://www.nikefactoryoutletstores.us.com

http://www.columbiasportswearoutlet-inc.com

http://www.michaelkorsbags.in.net

http://www.katespade-outlet.net.co

http://www.pradaoutletonlinestore.us.com

http://www.michaelkors--outlet.us.org

http://www.coachfactoryoutletonlineofficial.us.com

http://www.airjordan-14.us

http://www.ray-banwayfarer.me.uk

http://www.jordanretro.us

http://www.nikeoutletstore.us.com

http://www.sac-longchamppas-cher.fr

http://www.manoloblahnik.us

http://www.funoase.at

http://www.redbottoms.me.uk

http://www.pandorajewelryoutlet.us.org

http://www.michaeljordan-shoes.com

http://www.michael--kors--canada.ca

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

http://www.coachcanadaoutlet.com.co

http://www.vansshoesoutlet.us.com

http://www.coachhandbags-onlineoutlet.us.com

http://www.dardanet.se/rolex.html

http://www.valentinoshoes-outlet.us.com

http://www.coachfactoryoutletstore-online.us.com

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

http://www.coachoutletonlineshop.us.com

http://www.ctss.se/Nike Air Max.html

http://www.ralphlauren.eu.com

http://www.levisjeans.us.com

http://www.michaelkorsoutletonlinesale.us.com

http://www.noltingorgelgendringen.nl

http://www.clarksshoesoutlet-online.com

http://www.tory-burchoutletonline.us.com

http://www.christianlouboutinonlineoutlet.us.com

http://www.suprashoesoutlet-inc.com

http://www.oakley--sunglasseswholesale.us.com

http://www.suprashoes.in.net

http://www.raybansunglassesoutlet.net.co

http://www.michaelkorstote.us.com

http://www.catboots.us.com

http://www.ferragamoshoesoutlet.us.com

http://www.nikesb.us

http://www.hermes.in.net

http://www.hermesbirkinhandbags.us.com

http://www.adidasoriginalsshoes.in.net

http://www.michaelkors--outlet.com.co

http://www.converseshoesoutlet.us.com

http://www.realfres.es

http://www.michaelkorsoutletstores.us.org

http://www.christianlouboutin.me.uk

http://www.cheapraybansunglasses.net.co

http://www.mlbjerseyswholesale.us.com

http://www.ralphlaurenoutletofficial.us.com

http://www.adidas-nmdr1.us.com

http://www.pradabags.in.net

http://www.burberryhandbagsoutlets.us.com

http://www.adidasukoriginals.org.uk

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

http://www.michaelkorsoutletonlineshop.us.com

http://www.cheapjordansshoes.in.net

http://www.coachoutletpurses.us.com

http://www.burberrysale.net.co

http://www.coachoutletsclearance.us.com

http://www.adidassoccershoes.us

http://www.christianlouboutinoff.us

http://www.mizunorunningshoes.us.com

http://www.ed-hardy.us.org

http://www.nike-rosherun.in.net

http://www.ctss.se/Ray Ban.html

http://www.michaelkors.me.uk

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

http://www.officialcoachfactoryonlinesale.us.com

http://www.mbt.us.com

http://www.uggbootsclearance.net.co

http://www.adidas-neo.us.com

http://www.thenorthfacesale.us.com

http://www.oakleysunglassescanada.ca

http://www.coachfactoryoutletonlinesale.us.com

http://www.michaelkors-outlet.nom.co

http://www.guccishoes.net.co

http://www.adidassuperstar.name

http://www.cheapchristianlouboutinshoes.us.com

http://www.michaelkorstotebags.us.com

http://www.birkenstockoutlet.us.org

http://www.manchesterunitedjersey.co.uk

http://www.mathcad.be

http://www.nikeairforce1.in.net

http://www.katespadeoutletsale.us.com

http://www.truereligionjeans-outlet.us.com

http://www.pandoraoutlet.us.org

http://www.uggbootsclearances.com.co

http://www.eccoshoes.in.net

http://www.asics.in.net

http://www.nikeroshe.us.com

http://www.maccosmeticsonline.us.com

http://www.coachoutlet-purses.us.com

http://www.christianlouboutin.name

http://www.truereligionoutlet.eu

http://www.coachhandbags.cc

http://www.jaggabite.nl

http://www.nikefactory-outlet.com

http://www.archivigramsci.it

http://www.kobe12shoes.us.com

http://www.softworx.it

http://www.kate-spadeoutletonline.us.com

http://www.salvatore-ferragamo-outlet.in.net

http://cheapoakley.sunglassesonline.us.com

http://www.pandora-rings.net

http://www.poloralphlauren-outlet.com

http://www.michaelkorsoutletonline.us.org

http://www.hermesbeltoutlet.com

http://www.vans-store.in.net

http://www.adidasyeezy-boost350v2.us

http://www.cheapjordansshoes.us.com

http://www.michaelkorsuk.com.co

http://www.mcm.us.org

http://www.ray-banssunglasses.com.co

http://www.shopxpert.dk

http://www.supop.fr

http://www.sproeiendekutjes.nl

http://www.the-northfaceoutlet.net.co

http://www.outletnike.org

http://www.lebronjamesshoes14.us

http://www.replica-watches.us.com

http://www.vansshoes.us.org

http://www.polo-ralphlaurenshirts.us.com

http://www.vayrocana.de

http://www.michaelkorsoutletcanada.com.co

http://www.nfljerseyswholesalecheap.us.com

http://www.grupolanda.es

http://www.nylonic.co.uk

http://www.yeezys350boostv2.us.com

http://www.new-balanceshoes.us.com

http://www.longchamp-outlet.us.org

http://www.louis-vuittonoutlet.net.co

http://www.pradahandbagsoutlet.us.com

http://www.burberryoutlet-online.cc

http://www.adidas-nmdxr1.us.com

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

http://www.cheap-jordan-shoes.us.com

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

http://www.nikesoccershoes.us.com

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

http://www.poloralphlauren--outlet.us.com

http://www.underarmouroutletclearance.com

http://www.fitflopssaleuk.org.uk

http://www.villafranchi.it

http://www.converse.in.net

http://www.recoilmag.com.au/christian-louboutin.html

http://www.lecoqsportifshoes.us.com

http://www.michael--korsoutlet.us

http://www.michael--kors--outlet.ca

http://www.michaelkorsoutletsale.us.org

http://www.prada.us.org

http://www.clarksoutlet.in.net

http://www.nikeairmax2017.org

http://www.pandoracharms.us.org

http://www.mcm.com.co

http://www.raybanssunglasses.com.co

http://www.adidasyeezy-boost350v2.us.com

http://www.columbiashoes.us.com

http://www.coachsfactoryoutlet.us.com

http://www.ralphlaurenukofficial.org.uk

http://www.kevindurant9shoes.org

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

http://www.rosherun.org

http://www.nikehuarache.in.net

http://www.adidastrainersuk.co.uk

http://www.cheapoakleysunglasses.net.co

http://www.converseshoes.us.org

http://www.nikeroshe.org.uk

http://www.oakleysunglassesoutletwholesale.us.org

http://www.converse-outletstore.com

http://www.airmaxuk.uk

http://www.poloralphlaurenuk.uk

http://www.recoilmag.com.au/rolex.html

http://www.adidasyeezy350.us.com

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

http://www.katespade.nom.co

http://www.raybanwayfarer.com.co

http://www.canadagoosesale.com.co

http://www.vitax.se

http://www.adidasoutletstore.net

http://www.aididasyeezy.org.uk

http://www.cheapnhljersey.us.com

http://www.mlbjerseys.org

http://www.jordans.in.net

http://www.nikeairmax2016.in.net

http://www.michael-kors--handbags.com

http://www.coachfacyoryoutletonlinee.us.com

http://www.birkenstock.us.org

http://www.poloshirtsralphlauren.us.com

http://www.raybansonsale.com.co

http://www.yslhandbags.us

http://www.ferragamobelt.us.com

http://www.michaelkorsoutletclearance.us.org

chenyingying20170701

Comment by chneyingying 11 weeks and 6 days ago

Your point of view

You must be signed in to comment.