SCP命令是用户通过网络将一台Linux服务器的文件复制到另一台Linux服务器,方法如下:
一:从本地复制到远程
复制文件:
命令格式: scp local_file [email protected]_ip:remote_folder
例子:
scp /home/space/music/1.mp3 [email protected]:/home/root/others/music
scp /home/space/music/1.mp3 [email protected]:/home/root/others/music/001.mp3
scp /home/space/music/1.mp3 www.xxx.xxx.cn:/home/root/others/music
scp /home/space/music/1.mp3 www.xxx.xxx.cn:/home/root/others/music/001.mp3
复制目录:
命令格式: scp -r local_folder [email protected]_ip:remote_folder
或者 scp -r local_folder remote_ip:remote_folder
例子:
scp -r /home/space/music/ [email protected]:/home/root/others/
scp -r /home/space/music/ www.xxx.xxx.cn:/home/root/others/
上面命令是将本地 music 目录复制到远程 others 目录下,即复制后远程服务器中有 ../others/music/ 目录
二:从远程复制到本地
从远程复制到本地,只要将从本地复制到远程的命令的后2个参数调换顺 即可;
例如:
scp [email protected]:/home/root/others/music /home/space/music/1.mp3
scp -r www.xxx.xxx.cn:/home/root/others/ /home/space/music/