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

move a lot of files over ssh

Terminal - move a lot of files over ssh
tar -cf - /home/user/test | gzip -c | ssh [email protected] 'cd /tmp; tar xfz -'
2009-08-24 18:35:38
User: esplinter
Functions: gzip ssh tar
move a lot of files over ssh

Useful to move many files (thousands or millions files) over ssh. Faster than scp because this way you save a lot of tcp connection establishments (syn/ack packets).

If using a fast lan (I have just tested gigabyte ethernet) it is faster to not compress the data so the command would be:

tar -cf - /home/user/test | ssh [email protected] 'cd /tmp; tar xf -'


There are 11 alternatives - vote for the best!

Terminal - Alternatives
rsync -az /home/user/test [email protected]:/tmp/
2009-08-25 10:45:15
User: peshay
Functions: rsync
Tags: ssh file move

copy files to a ssh server with gzip compression

tar cfX - exclude_opt_weblogic . | ssh tmp-esxsb044 "cd /opt/weblogic ; tar xf -"

Know a better way?

If you can do better, submit your command here.

What others think

tar -czf and you spare that gzip pipe

Comment by lv4tech 374 weeks and 2 days ago

why not try a nc? Here, I am assuming that you have shells open in both the systems. The netcat manual has an example which does just that.

@lv4tech : i believe that tar internally does the same, pipes it to gzip if its -z, and bzip2 if its -j.

Comment by ninadsp 374 weeks and 2 days ago

You could also have ssh use a different (maybe less "secure") cipher like Blowfish or RC4:

tar -zcf - dirname | ssh -C blowfish-cbc [email protected] "cd /tmp; tar xfz -"

see the different speeds yourself:

openssl speed aes rc4 blowfish

It'd be interesting to see how nc does versus ssh -C with blowfish or rc4/arcfour.

Comment by bwoodacre 374 weeks and 2 days ago

Is this really saving tcp connection establishment? I tried this with many mp3 files and what I observed was, as soon as I start running it, I start seeing mp3 files in destination. So, it looks like, as if, tar is archiving/compressing single mp3, sending it through ssh and then single archive file is uncompressed at destination. So, my question is, in this case, does tar archive files one by one or compress them into single archive?

Comment by alperyilmaz 338 weeks and 6 days ago

the tar xfz on the ssh side should be zxf

Comment by elilindner 175 weeks and 1 day ago

@alperyilmaz: Yes, tar creates a stream of files. Think if it as a multi-file cat command. As the stream is sent over the wire it is one TCP connection, The tar command would then write those files as the stream comes across there by looking like it is file by file.

Comment by Sukima 115 weeks and 3 days ago

Your point of view

You must be signed in to comment.