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

Create a local compressed tarball from remote host directory

Terminal - Create a local compressed tarball from remote host directory
ssh [email protected] "tar -cf - /path/to/dir" | gzip > dir.tar.gz
2011-12-14 15:54:57
User: atoponce
Functions: gzip ssh
7
Create a local compressed tarball from remote host directory

The command uses ssh(1) to get to a remote host, uses tar(1) to archive a remote directory, prints the result to STDOUT, which is piped to gzip(1) to compress to a local file. In other words, we are archiving and compressing a remote directory to our local box.

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives
ssh [email protected] "tar -zcf - /path/to/dir" > dir.tar.gz
2011-12-16 05:48:38
User: __
Functions: ssh
Tags: ssh tar gzip
20

This improves on #9892 by compressing the directory on the remote machine so that the amount of data transferred over the network is much smaller. The command uses ssh(1) to get to a remote host, uses tar(1) to archive and compress a remote directory, prints the result to STDOUT, which is written to a local file. In other words, we are archiving and compressing a remote directory to our local box.

ssh [email protected] "tar -czf - /path/to/dir" > dir.tar.gz

Know a better way?

If you can do better, submit your command here.

What others think

Useful +1

Comment by zlemini 245 weeks and 4 days ago

I needed to add some redirection after the pipe:

| gzip > dir.tar.gz
Comment by zlemini 245 weeks and 4 days ago

@zlemini Ah, yes. Simple typo, and fixed. Thanks!

Comment by atoponce 245 weeks and 4 days ago

Better to do the compression on the remote side; use 'tar czf' over there and just write it straight to a file here.

Comment by Mozai 245 weeks and 3 days ago

@Mozai I wouldn't necessarily say that doing compression remotely is "better", but it's certainly an alternate way of doing the command. If you're concerned about data bandwidth on the wire, OpenSSH (and many other SSH implementations) support compression to varying degrees. Lastly, not all tar(1) implementations support compression builtin. Best to keep the command 100% portable, as much as possible, than relying on platform-specific enhancements.

Comment by atoponce 245 weeks and 3 days ago

There may be times where you have plenty of bandwidth but very short of remote processor so this could be useful in that case. I'd say it's usually better to do the compression on the remote side, though. You certainly wouldn't want to use ssh compression, because then you'd be compressing, decompressing, and compressing again. If your tar doesn't have the z option, you would use this:

ssh [email protected] "tar -cf - /path/to/dir | gzip" > dir.tar.gz

Also, if you didn't want "/path/to/dir" in each archive filename, you could do:

ssh [email protected] "cd /path/to/dir; tar -cf - . | gzip" > dir.tar.gz
Comment by splante 242 weeks and 6 days ago

you can use rsh with tar and gzip ,,,this url will guide you with examples.....

http://unixcommandstutorial.blogspot.in/2012/01/gzip-and-tar.html

Comment by parashuramsingh 238 weeks ago

http://www.longchamp-solde.fr

http://www.sac-louisvuittonpascher.fr

http://www.swarovski.in.net

http://www.truereligionjeansoutlet.com

http://www.tomsoutlet-stores.com

http://www.timberlandboots.me.uk

http://www.christianlouboutinuk.org.uk

http://www.michaelkorsusa.us

http://www.saclongchamp-pliage.fr

http://www.jordanshoes.us.com

http://www.airforce1.us.com

http://www.longchampoutlet.name

http://www.rolexwatches.in.net

http://www.nikeairmax90.me.uk

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

http://www.coachoutletcanada.com.co

http://www.christianlouboutinoutlet.me.uk

http://www.truereligionoutlet-store.us.com

http://www.nikerosherunwomen.co.uk

http://www.nike-mercurial.net

http://www.hermesbirkin.org

http://www.michaelkorsoutletonlinstore.us.com

http://www.hermesbelts.us

http://www.nikeairmax90.org.uk

http://www.fitflop.in.net

http://www.michaelkorsoutletonline.in.net

http://www.mcm.in.net

http://www.michaelkorsoutlets.org.uk

http://www.lacostepoloshirts.cc

http://www.truereligionjeanscanada.com

http://www.thomassabos.co.uk

http://www.coachoutletstore.com.co

http://www.ralphlaurenoutlet.in.net

http://www.louisvuittonus.us.com

http://www.truereligionjeansoutlets.us.com

http://www.louisvuitton.in.net

http://www.coachoutletstores.com.co

http://www.cheapmichaelkorshandbag.in.net

http://www.cheapnfljerseys.org

http://www.outletswarovski.co.uk

http://www.toms.us.com

http://www.louboutinpas-cher.fr

http://www.swarovskicrystal.me.uk

http://www.hermesoutletstore.us.com

http://www.kobebryantshoes.in.net

http://www.louisvuittonoutletstore.name

http://www.cheapmlbjerseys.us.com

http://www.nike-airhuarache.co.uk

http://www.truereligion-jean.us.com

http://www.iphone-cases.name

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

http://www.pandorajewelryoutlet.us.com

http://www.tiffanyjewellery-outlet.co.uk

http://www.burberryonlineoutlet.in.net

http://www.reeboktrainers.org.uk

http://www.christianlouboutinonline.us.com

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

http://www.nikeairmax90.co.uk

http://www.pandora.eu.com

http://www.mont-blancpens.com.co

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

http://www.raybansunglassesonline.us.com

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

http://www.louisvuittonhandbagsoutlet.co.uk

http://www.michaelkorsfactoryoutlets.in.net

http://www.michaelkorsoutlet-store.us.com

http://www.poloralphlaurenshirts.us.com

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

http://www.michaelkorshandbagsale.us.com

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

http://www.rolexwatches-uk.co.uk

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

http://www.michaelkorsclearance.in.net

http://www.cheapmlbjerseys.net

http://www.air-jordanshoes.us.com

http://michaelkors.outletonlinestores.us.com

http://www.adidasoutletstore.in.net

http://www.ralphlauren-pascher.fr

http://www.discountmichaelkorshandbags.in.net

http://www.juicycoutureoutlet.net

http://www.louisvuittonoutlet.in.net

http://www.cheapsoccerjersey.net

http://mulberryoutlet.outlet-store.co.uk

http://michaelkors.outletstoreonline.us.com

http://www.lebronjamesshoes.in.net

http://www.beats-headphones.in.net

http://www.michaelkorshandbagsoutletstore.us.com

http://www.niketnpas-cher.fr

http://www.michaelkorssale.in.net

http://www.swarovskicrystal.us.com

http://www.nikeairmaxshoess.co.uk

http://www.timberlandboots.name

http://www.basketballshoes.us.com

http://www.soccerjerseys.us.com

http://www.adidas-wings.in.net

http://www.pradaoutlet.us

http://www.michaelkorsoutletonlinestores.us.com

http://www.lebronjames.us.com

http://www.michaelkorsfactoryoutlet.us.org

http://www.futbol-baratas.com

http://www.nikeairhuarache.org.uk

http://www.michaelkorshandbagsclearances.us.com

http://www.hermesbags.co.uk

http://www.raybansun-glasses.in.net

http://www.linksoflondons.co.uk

http://www.michaelkorsoutletclearance.us.com

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

http://www.michaelkorswallet.net

http://www.airmax2015.in.net

http://www.chaussurelouboutin.fr

http://www.longchamppas-cher.fr

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

http://www.pololacostepascher.fr

http://www.nikeblazerpas-cher.fr

http://www.kobeshoes.us

http://www.pradahandbagsoutlet.co.uk

http://www.asicsisrael.com

http://www.michaelkorsoutletcanada.in.net

http://www.birkenstock.us.com

http://www.michaelkorswholesale.us.com

http://www.ralphlaurenpolo.it

http://www.outletmulberry.co.uk

http://www.raybansunglass.com.au

http://www.longchamppliage.fr

http://www.michaelkorsoutlet.org.uk

http://www.pradashoes.us

http://www.michaelkorshandbags.in.net

http://www.mbtshoesoutlet.us.com

http://www.louisvuittonbag.us.com

http://www.raybansunglass.us.com

http://www.beatsbydrdre-headphones.us.com

http://www.calvinklein.in.net

http://www.michaelkorsbags.uk

http://www.adidastrainers.me.uk

http://www.cheapfootballshirt.org.uk

http://www.nikeairforce1.fr

http://www.jordan-pascher.fr

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

http://www.herveleger.us.com

http://www.reebokoutletstore.us.com

http://www.michaelkorsoutletusa.net

http://www.louisvuittonhandbag.us

http://www.longchamphandbag.us.com

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

http://www.michaelkorsonlinesale.us.com

http://www.louisvuittonhandbags.org.uk

20160323caihuali

Comment by xiaozhengm 22 weeks and 5 days ago

Your point of view

You must be signed in to comment.