標籤:
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/
Linux SCP命令複製傳輸檔案的用法