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 | RemoteDirectory指定要更改的远程计算机上的目录。 | dir | 显示远程计算机上的目录文件和子目录列表 | dir [RemoteDirectory] [LocalFile] | RemoteDirectory指定要查看其列表的目录。如果没有指定目录,将使用远程计算机中的当前工作目录。
LocalFile指定要存储列表的本地文件。如果没有指定本地文件,则屏幕上将显示结果。 | get | 使用当前文件传输类型将远程文件复制到本地计算机。如果没有指定 LocalFile,文件就会赋以 RemoteFile 名。get 命令与 recv 相同。 | get RemoteFile [LocalFile] | RemoteFile指定要复制的远程文件。
LocalFile指定要在本地计算机上使用的文件名。 | lcd | 更改本地计算机上的工作目录。默认情况下,工作目录是启动 ftp 的目录 | lcd [Directory] | Directory指定要更改的本地计算机上的目录。如果没有指定 Directory,将显示本地计算机中的当前工作目录。 | ls | 显示远程目录上的文件和子目录的简短列表 | ls [RemoteDirectory] [LocalFile] | RemoteDirectory指定要查看其列表的目录。如果没有指定目录,将使用远程计算机中的当前工作目录。
LocalFile指定要存储列表的本地文件。如果没有指定本地文件,将在屏幕上显示结果。 | open | 与指定的 FTP 服务器连接。可以使用 IP 地址或计算机名(两种情况下都必须使用 DNS 服务器或主机文件)指定 Computer。 | open Computer [Port] | Computer必需。指定试图要连接的远程计算机。
Port指定用于联系 FTP 服务器的 TCP 端口号。默认情况下,使用 TCP 端口号 21。 | put(send) | 使用当前文件传输类型将本地文件复制到远程计算机上。put 命令与 send 命令相同。如果没有指定 RemoteFile,文件就会赋以 LocalFile 名。 | put LocalFile [RemoteFile] | LocalFile指定要复制的本地文件。
RemoteFile指定要在远程计算机上使用的名称。 |
更多详细的说明请看http://technet.microsoft.com/zh-cn/library/cc756013(v=ws.10).aspx 和 http://blog.iyunv.com/chaoqunz/article/details/5973317
|