cp 復制文件(copy)
cp sourcefile destfile
scp 跨服務器復制(secure copy)
(1) 復制文件:
scp local_file remote_username@remote_ip:remote_folder
或
scp local_file remote_username@remote_ip:remote_file
或
scp local_file remote_ip:remote_folder
或
scp local_file remote_ip:remote_file
第1,2個指定了用戶名,命令執行后需要輸入密碼,第1個僅指定了遠程的目錄,文件名字不變,第2個指定了文件名
第3,4個沒有指定用戶名,命令執行后需要輸入用戶名和密碼,第3個僅指定了遠程的目錄,文件名字不變,第4個指定了文件名
scp -r 復制目錄:
scp -r local_folder remote_username@remote_ip:remote_folder
或者
scp -r local_folder remote_ip:remote_folder
第1個指定了用戶名,命令執行后需要輸入密碼;
第2個沒有指定用戶名,命令執行后需要輸入用戶名和密碼
后面兩個參數互換則表示遠程服務器復制到本地服務器
例如:從遠程服務器復制文件到本地目錄:
scp root@127.0.0.1:/opt/soft/nginx-0.5.39.tar.gz /opt/soft/