1.系統環境
FTP客戶端:Windows7旗艦版,管理員權限命令行;
FTP服務端:CentOS 6.5,VSFTP,端口 21(默認)
2.登陸FTP
- 在命令行下輸入 ftp,出現 ftp>即進入FTP命令行
- open FTP的IP地址/域名 例如 open 169.254.234.241 (當然有最簡單的方式 直接在命令行下 ftp FTP的IP地址/域名)
- 按照提示輸入用戶名和密碼,完成登陸
Microsoft Windows [版本 6.1.7601] 版權所有 (c) 2009 Microsoft Corporation。保留所有權利。 C:\Users\Administrator>ftp ftp> open 169.254.234.241 連接到 169.254.234.241。 220 Welcome to blah FTP service. 用戶(169.254.234.241:(none)): wy 331 Please specify the password. 密碼: 230 Login successful. ftp>
3.上傳一個文件
- put(或者 send,上傳多個使用 mput) 文件名(包含路徑) 例如 put C:\Users\Administrator\Documents\Myself.pub
- ls(或者 dir) 查看當前目錄文件
ftp> put C:\Users\Administrator\Documents\Myself.pub 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 Transfer complete. ftp: 發送 233 字節,用時 0.02秒 14.56千字節/秒。 ftp> send C:\Users\Administrator\Documents\Myself 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 Transfer complete. ftp: 發送 1004 字節,用時 0.00秒 1004000.00千字節/秒 ftp> ls 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. Myself Myself.pub 226 Directory send OK. ftp: 收到 20 字節,用時 0.00秒 20.00千字節/秒。 ftp>
很顯然,send 的速度比 put 快不少。但是他們兩個的區別我沒有詳細的查。
4.下載一個文件
- lcd 本地目錄路徑 設置當前工作路徑,也就是你要把文件下載到哪。默認是在當前使用命令行的用戶的主目錄。我的是 C:\Users\Administrator。也可以使用 !chdir 查看當前目錄。
- cd 服務器目錄 進入到你要下載的文件在服務器端的目錄位置
- get(下載多個用 mget) 文件名 下載該文件。例如 get Myself
- !dir 查看當前目錄文件,就能看到你剛才下載的文件啦
ftp> dir 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. -rw-r--r-- 1 500 500 986 Dec 03 10:08 Myself -rw-r--r-- 1 500 500 233 Dec 03 10:07 Myself.pub 226 Directory send OK. ftp: 收到 132 字節,用時 0.00秒 132000.00千字節/秒。 ftp> !cd C:\Users\Administrator\Desktop ftp> !chdir C:\Users\Administrator ftp> lcd C:\Users\Administrator\Desktop 目前的本地目錄 C:\Users\Administrator\Desktop。 ftp> !chdir C:\Users\Administrator\Desktop ftp> get Myself 200 PORT command successful. Consider using PASV. 150 Opening ASCII mode data connection for Myself (986 bytes). 226 Transfer complete. ftp: 收到 1004 字節,用時 0.00秒 1004.00千字節/秒。 ftp> dir 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. -rw-r--r-- 1 500 500 986 Dec 03 10:08 Myself -rw-r--r-- 1 500 500 233 Dec 03 10:07 Myself.pub 226 Directory send OK. ftp: 收到 132 字節,用時 0.00秒 132.00千字節/秒。 ftp> !dir 驅動器 C 中的卷沒有標簽。 卷的序列號是 941F-307E C:\Users\Administrator\Desktop 的目錄 2013/12/03 18:27 <DIR> . 2013/12/03 18:27 <DIR> .. 2013/11/17 13:23 932 Evernote.lnk 2013/11/24 15:43 1,023 FlashFXP.lnk 2013/11/21 08:53 2,176 Git Shell.lnk 2013/11/21 08:53 308 GitHub.appref-ms 2013/12/03 18:27 1,004 Myself 2013/10/26 21:26 1,627 SecureCRT.lnk 6 個文件 7,070 字節 2 個目錄 50,591,227,904 可用字節 ftp>
5.斷開連接
bye 就是這樣。
ftp> status 連接到 169.254.234.241。 類型: ascii;詳細: 開 ;鈴聲: 關 ;提示: 開 ;通配: 開 調試: 關 ;哈希標記打印: 關 。 ftp> bye 221 Goodbye. C:\Users\Administrator>
6.總結
這里就是拿一個例子來說明了一下簡單的上傳和下載命令的使用。使用 help 和 help [Command] 來查看對應命令的解釋。最后給出常用命令的說明和格式。
命令 | 說明 | 格式 | 參數說明 |
bye | 結束與遠程計算機的 FTP 會話並退出 ftp | bye | |
cd | 更改遠程計算機上的工作目錄 | cd RemoteDirectory |
|
dir | 顯示遠程計算機上的目錄文件和子目錄列表 | dir [RemoteDirectory] [LocalFile] |
|
get | 使用當前文件傳輸類型將遠程文件復制到本地計算機。如果沒有指定 LocalFile,文件就會賦以 RemoteFile 名。get 命令與 recv 相同。 |
get RemoteFile [LocalFile] |
|
lcd | 更改本地計算機上的工作目錄。默認情況下,工作目錄是啟動 ftp 的目錄 | lcd [Directory] |
|
ls | 顯示遠程目錄上的文件和子目錄的簡短列表 | ls [RemoteDirectory] [LocalFile] |
|
open | 與指定的 FTP 服務器連接。可以使用 IP 地址或計算機名(兩種情況下都必須使用 DNS 服務器或主機文件)指定 Computer。 | open Computer [Port] |
|
put(send) | 使用當前文件傳輸類型將本地文件復制到遠程計算機上。put 命令與 send 命令相同。如果沒有指定 RemoteFile,文件就會賦以 LocalFile 名。 |
put LocalFile [RemoteFile] |
|
更多詳細的說明請看http://technet.microsoft.com/zh-cn/library/cc756013(v=ws.10).aspx 和 http://blog.csdn.net/chaoqunz/article/details/5973317