現(xiàn)在的很多遠(yuǎn)程連接工具比如XShell或MobaXterm都有提供上傳和下載的功能,除此之外,一些Linux終端的命令比如scp、sftp也可以實現(xiàn)這類功能,并且更為靈活和便捷,不但可以滿足本地與服務(wù)器之間的傳輸,也能在兩臺遠(yuǎn)程服務(wù)器之間相互傳送文件。下面介紹scp的一些用法。
將本地文件復(fù)制到服務(wù)器
scp localmachine/path_to_the_file username@server_ip:/path_to_remote_directory
這里的localmachine/path_to_the_file是本地文件的路徑,username@server_ip是服務(wù)器的用戶名和ip,后面接的是服務(wù)器上的路徑。運行命令,輸入服務(wù)器的登錄密碼后,文件即被上傳到了服務(wù)器/path_to_remote_directory的位置。
如果我們想復(fù)制整個文件夾中的內(nèi)容到遠(yuǎn)程服務(wù)器呢?也非常簡單,只需要加上一個參數(shù)-r,
scp -r localmachine/path_to_the_file username@server_ip:/path_to_remote_directory
從服務(wù)器復(fù)制文件到本地
如果是想獲取服務(wù)器上的文件,只需要對上述命令稍加修改:
scp username@server_ip:/path_to_remote_directory local_machine/path_to_the_file
同理,如果是獲取服務(wù)器上的一個文件夾,也是加上參數(shù)-r:文章來源:http://www.zghlxwxcb.cn/news/detail-691086.html
scp -r username@server_ip:/path_to_remote_directory local_machine/path_to_the_file
復(fù)制服務(wù)器上的文件到另外一臺服務(wù)器
假設(shè)我們沒有登錄服務(wù)器,想復(fù)制一臺服務(wù)器中的文件到另外一臺服務(wù)上面去:文章來源地址http://www.zghlxwxcb.cn/news/detail-691086.html
scp username@server1_ip:/path_to_the_remote_fileusername@server2_ip:/path_to_destination_direcory/
到了這里,關(guān)于Linux如何在本地/服務(wù)器間傳輸文件的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!