Go to ...

Techpository

A Better Technical Repository

RSS Feed

Linux: SCP tricks


Quite a handy thing about scp is that it supports asterisks. You can copy all files in a remote directory in a way like this:

scp [email protected]:/home/yourusername/* .

And you can also just copy a whole directory by specifying the -r (recursive) option:

scp -r [email protected]:/home/yourusername/ .

Both of these also work when copying to a (remote) server or copying between a (remote) server and another (remote) server.

You can also limit the bandwidth scp may use when copying. This is very useful if you’re wanting to copy a huge amount of data without suffering from slow internet for a long time. Limiting bandwidth is done this way:

scp -l bandwidthlimit [email protected]:/home/yourusername/* .

The bandwidth is specified in Kbit/sec. What does this mean? Eight bits is one byte. If you want to copy no faster than 10 Kbyte/sec, set the limit to 80. If you want to copy no faster than 80 Kbyte/sec, set the limit to 640. Get it? You should set the limit to eight times the maximum Kbyte/sec you want it to be. I’d recommend to set the -l option with all scp’ing you do on a connection that other people need to use, too. A big amount of copying can virtually block a whole 10 Mbit network if you’re using hubs.

By: rechosen