Linux Commands for Dummies - scp / copy files between servers

in linux •  7 years ago 

Hi guys!
Today i wanna show you the "scp" command in linux. It's an extremely useful command that i use daily. It comes bassicly with every linux distro. Essentially it lets you copy files from one linux PC to another in a secure manner. All you need is a SSH Server on the receiving server which most linux distros have out of the box.

So how does it work?

scp somefile.txt user@server:/somefolder/somefile.txt

Ok lets take a look what is happening here. The file "somefile.txt" from my local folder gets copied to the server to "somefolder". The user you use is the one you normally would use for your ssh login.
"server" can be any servername or ip.

Lets see another example:

scp -R /home/root [email protected]:/home

This would copy the whole folder (/home/root) and its subdirectories to the ip "192.168.1.10" into the "home" folder.

This is really awesome when setting up a new server and you wanna copy the config files from an old machine. Lots of people use software like WinScp to copy stuff back and forth which is basically the same in a Windows gui, it might be more convenient but for for a quick copy i really prefer the commandline version.

Their a few usefull options you may like to use, the first that come to my mind is:

-C this will enable compression which is very useful for large amounts of files.

-I limit the transfer speed in kilobytes

Hope this gives you some insight on SCP. Feel free to ask questions or give any other comments.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!