無論使用何種作業系統,FTP 指令都是檔案傳輸中使用頻率最高的工具。掌握這些指令能讓您事半功倍。本文整理了 FTP 指令列參數與 38 個核心內部命令,附帶中文說明與範例。
ftp -v -d -i -n -g [主機名]
-v 顯示遠端伺服器所有回應資訊-n 限制自動登入(不使用 .netrc)-i 關閉互動模式-d 除錯模式-g 取消全域檔名擴展| 命令 | 功能說明 | 範例 |
|---|---|---|
![cmd [args]] | 在本機執行互動 shell,exit 返回 ftp | !ls *.zip |
$ macro-name [args] | 執行巨集定義 | |
account [password] | 提供登入後存取資源所需補充密碼 | |
append local-file [remote-file] | 將本地檔案附加到遠端主機 | |
ascii | 使用 ASCII 傳輸模式 | |
bell | 每個命令執行完畢響鈴一次 | |
bin / image | 使用二進位傳輸模式 | |
bye | 結束 FTP 會話 | |
case | mget 時將遠端大寫檔名轉小寫 | |
cd remote-dir | 進入遠端目錄 | |
cdup | 進入遠端父目錄 | |
chmod mode file-name | 設定遠端檔案存取模式 | chmod 777 a.out |
close | 中斷與遠端伺服器的會話 | |
cr | ASCII 傳輸時將 CRLF 轉為 LF | |
delete remote-file | 刪除遠端檔案 | |
debug [value] | 設定除錯等級,0 為關閉 | debug up 3 |
dir [remote-dir] [local-file] | 顯示遠端目錄並存入本地檔案 | |
disconnection | 同 close | |
form format | 設定檔案傳輸格式,預設 file | |
get remote-file [local-file] | 下載遠端檔案到本地 | |
glob | 設定 mdelete/mget/mput 檔名擴展 | |
hash | 每傳輸 1024 bytes 顯示一個 # | |
help [cmd] | 顯示內部命令說明 | help get |
idle [seconds] | 設定遠端伺服器閒置計時器 | |
lcd [dir] | 切換本地工作目錄 | |
ls [remote-dir] [local-file] | 顯示遠端目錄清單並存入本地 | |
macdef macro-name | 定義巨集,空行結束 | |
mdelete [remote-file] | 刪除多個遠端檔案 | |
mdir remote-files local-file | 類似 dir 但可指定多個遠端檔案 | mdir *.o *.zip outfile |
mget remote-files | 下載多個遠端檔案 | |
mkdir dir-name | 在遠端建立目錄 | |
mls remote-file local-file | 同 nlist 但可指定多檔案 | |
mode [modename] | 設定傳輸模式,預設 stream | |
modtime file-name | 顯示遠端檔案最後修改時間 | |
mput local-file | 上傳多個本地檔案到遠端 | |
newer file-name | 遠端檔案較新時重新傳輸 | |
nlist [remote-dir] [local-file] | 顯示遠端目錄檔案清單並存入本地 |