萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 作業系統 >  >> Linux 教學

Linux 指令操作 FTP 完整教學:連線、上傳、下載、批次傳輸

在無圖形介面的 Linux 伺服器環境,ftp 指令是檔案傳輸的基本工具。本文以實際連線範例,詳細說明 FTP 互動模式下的常用指令與參數,涵蓋單一/批次上傳下載、目錄切換、斷線等完整流程。

實戰連線範例

-bash-3.00$ ftp rws60001rems.us.oracle.com
Connected to rws60001rems.us.oracle.com (139.185.21.141).
220 (vsFTPd 1.2.1)
Name (rws60001rems.us.oracle.com:app7740): xxxxx
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (139,185,21,141,216,189)
150 Here comes the directory listing.
-rw-r--r-- 1 60202384 60402384 524 Aug 08 00:37 temp1.out
226 Directory send OK.
ftp> pwd
257 "/slot/ems2384/appmgr"
ftp> get temp1.out
local: temp1.out remote: temp1.out
227 Entering Passive Mode (139,185,21,141,126,148)
150 Opening BINARY mode data connection for temp1.out (524 bytes).
226 File send OK.
524 bytes received in 0.0017 secs (3e 02 Kbytes/sec)
ftp> put INVLTENT.plx_bk
local: INVLTENT.plx_bk remote: INVLTENT.plx_bk
227 Entering Passive Mode (139,185,21,141,109,145)
150 FILE: INVLTENT.plx_bk.1
226 File receive OK.
331776 bytes sent in 0.00457 secs (7.1e 04 Kbytes/sec)
ftp> bye
221 Goodbye.

核心指令分類

1. 連線登入

  • ftp [hostname|ip]:啟動連線,依提示輸入帳號密碼。

2. 下載檔案

  • get remote-file [local-file]:下載單一檔案,可指定本地檔名。
  • mget remote-files:批次下載(支援萬用字元),檔案存入本地目前目錄。

3. 上傳檔案

  • put local-file [remote-file]:上傳單一檔案,可指定遠端檔名/路徑。
  • mput local-files:批次上傳本地目前目錄下符合條件的檔案。

4. 目錄與環境操作

  • ls、cd、pwd:FTP 模式下同樣可用,操作遠端目錄。
  • lcd:切換本地工作目錄(影響上傳/下載預設路徑)。

5. 斷線離開

  • bye 或 quit:結束 FTP 會話。
FTP 連線範例畫面

掌握這些指令,即可在終端機高效完成伺服器間檔案同步與備份作業。

copyright © 萬盛學電腦網 all rights reserved