作用:用于远程拷贝文件
示例:
1)拷贝文件到远程服务器:
命令:scp -v /usr/file/examplefile username@192.168.102.165:/user/remote/copy/file
参数说明:/usr/file/examplefile — 只要拷贝的原文件路径
username — 远程服务器的用户名(用于拷贝文件的用户)
192.168.102.165 — 远程服务器的地址(也可以是域名)
/user/remote/copy/file - 文件复制到远程服务器的路径
-v - 打印命令执行过程中的信息。
命令:scp -r -f username@192.168.102.165:/user/remote/copy/ /usr/file/
参数说明:-r - 递归拷贝文件夹下的所有文件和子文件夹
-f - 强制替换本地已经存在的同名文件
其他参数和1)中的一样
示例:
1)拷贝文件到远程服务器:
命令:scp -v /usr/file/examplefile username@192.168.102.165:/user/remote/copy/file
参数说明:/usr/file/examplefile — 只要拷贝的原文件路径
username — 远程服务器的用户名(用于拷贝文件的用户)
192.168.102.165 — 远程服务器的地址(也可以是域名)
/user/remote/copy/file - 文件复制到远程服务器的路径
-v - 打印命令执行过程中的信息。
说明:命令执行后,会要求输入远程服务器username用户的密码。
命令:scp -r -f username@192.168.102.165:/user/remote/copy/ /usr/file/
参数说明:-r - 递归拷贝文件夹下的所有文件和子文件夹
-f - 强制替换本地已经存在的同名文件
其他参数和1)中的一样
注:第二天又练习了一下,发现加-f参数会导致无限等待。这个参数是不是无效的?