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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
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.
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
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:
This command will copy a folder tree (keeping the parent folders) through ssh. It will:
- compress the data
- stream the compressed data through ssh
- decompress the data on the local folder
This command will take no additional space on the host machine (no need to create compressed tar files, transfer it and then delete it on the host).
There is some situations (like mirroring a remote machine) where you simply cant wait for a huge time taking scp command or cant compress the data to a tarball on the host because of file system space limitation, so this command can do the job quite well.
This command performs very well mainly when a lot of data is involved in the process. If you copying a low amount of data, use scp instead (easier to type)
There are 5 alternatives - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.
In case you want to use fewer CPU cycles, you could just drop the gzip compression of tar (which is sometimes the bottleneck depending on the data), or use a different cipher in ssh:
ssh <host> -C blowfish-cbc 'tar -cz /<folder>/<subfolder>' | tar -xvzto profile the different ssh ciphers on your machine, run this command:
openssl speed aes rc4 blowfishAt least on debian/ubuntu, the openssl command comes with the 'openssl' package, which is probably available by default on most systems.
Nice comment, thx for the additions
You can let ssh do the compression/decompression:
ssh -C HOST 'tar -c PATH' | tar -xvThe advantage is that you can control the compression level, like:
ssh -C -o CompressionLevel=9 HOST 'tar -c PATH' | tar -xvDid some testes with the 3 versions of the commands (copying large log files)
time scp hula2:/export/logs/account-collector/server.log.2009-11-* .server.log.2009-11-01 100% 43MB 8.5MB/s 00:05
server.log.2009-11-02 100% 44MB 10.9MB/s 00:04
server.log.2009-11-03 100% 21MB 10.5MB/s 00:02
server.log.2009-11-04 100% 2302KB 2.3MB/s 00:00
server.log.2009-11-05 100% 785MB 9.7MB/s 01:21
server.log.2009-11-06 100% 50MB 8.3MB/s 00:06
server.log.2009-11-07 100% 21MB 10.4MB/s 00:02
server.log.2009-11-08 100% 20MB 10.2MB/s 00:02
server.log.2009-11-09 100% 5171KB 5.1MB/s 00:01
server.log.2009-11-10 100% 343MB 8.8MB/s 00:39
server.log.2009-11-11 100% 109MB 9.1MB/s 00:12
server.log.2009-11-12 100% 109MB 8.4MB/s 00:13
real 2m46.731s
user 0m25.078s
sys 0m10.113s
time ssh hula2 'tar -cz /export/logs/account-collector/server.log.2009-11-*' | tar -xvztar: Removing leading `/' from member names
export/logs/account-collector/server.log.2009-11-01
export/logs/account-collector/server.log.2009-11-02
export/logs/account-collector/server.log.2009-11-03
export/logs/account-collector/server.log.2009-11-04
export/logs/account-collector/server.log.2009-11-05
export/logs/account-collector/server.log.2009-11-06
export/logs/account-collector/server.log.2009-11-07
export/logs/account-collector/server.log.2009-11-08
export/logs/account-collector/server.log.2009-11-09
export/logs/account-collector/server.log.2009-11-10
export/logs/account-collector/server.log.2009-11-11
export/logs/account-collector/server.log.2009-11-12
real 1m8.055s
user 0m7.232s
sys 0m5.428s
time ssh -C hula2 'tar -c /export/logs/account-collector/server.log.2009-11-*' | tar -xvtar: Removing leading `/' from member names
export/logs/account-collector/server.log.2009-11-01
export/logs/account-collector/server.log.2009-11-02
export/logs/account-collector/server.log.2009-11-03
export/logs/account-collector/server.log.2009-11-04
export/logs/account-collector/server.log.2009-11-05
export/logs/account-collector/server.log.2009-11-06
export/logs/account-collector/server.log.2009-11-07
export/logs/account-collector/server.log.2009-11-08
export/logs/account-collector/server.log.2009-11-09
export/logs/account-collector/server.log.2009-11-10
export/logs/account-collector/server.log.2009-11-11
export/logs/account-collector/server.log.2009-11-12
real 1m28.785s
user 0m13.613s
sys 0m6.332s
The ssh -C option is a good alternative but it probably compresses by packet, achieving a lower compression when compared to compression by file.
Still the -C flag can be very useful.
Thx for the additions guys.