首页 > 技术文章 > Linux 命令 - ftp: 网络文件传输工具

huey 2015-10-15 00:54 原文

命令格式

ftp [-pinegvd] [host]

 

命令参数

-A
  传输文件模式为主动模式。

-p
  传输文件模式为被动模式。

-i
  关闭交互模式。

-n
  关闭自动登录功能。

-e
  不记录历史命令。

-g
  禁用文件名替换

-v
  命令执行时显示详细的处理信息。

-d
  启用调试。

 

FTP 内部命令

命令 说明
 ascii  使用 ASCII 传输方式。
 bell  每个命令执行完后响铃一次。
 bin  使用二进制传输方式。
 bye  结束 ftp 会话并退出程序。
 cd remote-directory   进入指定的远程目录。
 cdup  进入远程系统的父目录。
 chmod mode file-name   更改远程文件的权限模式。
 close  中断与远程服务器的 ftp 会话(与 open 相对应)。
 delete remote-file  删除远程系统的文件。
 debug  切换调试模式。
 dir [remote-directory] [local-file]   列出远程目录 remote-directory 的内容,并将结果保存至本地文件 local-file。 
 disconnection  同 close。
 get remote-file [local-file]  将远程目录的文件下载至本地目录。
 help [command]  显示内部命令的帮助信息。
 lcd  切换本地系统的工作目录。
 ls  列出远程系统上的目录列表。
 mkdir directory-name  在远程主机上创建一个目录。
 put local-file [remote-file]  将本地文件上传至远程目录。
 pwd  打印远程主机的当前工作目录。
 quit  同 bye。
 recv remote-file [local-file]  同 get。
 rename [from] [to]  重命名远程系统的文件。
 rmdir directory-name  删除远程系统的目录。
 send local-file [remote-file]  同 put。
 size file-name  显示远程文件的大小。
 status  显示当前 ftp 状态。
 system  显示远程主机的操作系统类型。
 umask [newmask]  设置远程系统的文件模式掩码值。
 user user-name [password] [account]   向远程主机表明自己的身份。

 

实例

a) 从 FTP 服务器 192.168.1.88 上的 /ggd/commons-jxpath-1.3.jar 目录中下载 文件至本地目录 ~/cmdline。

[huey@huey-K42JE ~]$ ftp 192.168.1.88
Connected to 192.168.1.88 (192.168.1.88).
220 (vsFTPd 2.2.2)
Name (192.168.1.88:huey): sugar
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 (10,1,231,4,178,241).
150 Here comes the directory listing.
drwxr-xr-x    2 505      501          4096 Aug 31 02:29 ggd
drwxr-xr-x    2 505      501          4096 Sep 02 03:22 ttd
226 Directory send OK.
ftp> cd ggd
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (10,1,231,4,184,4).
150 Here comes the directory listing.
-rw-r--r--    1 505      501       2738534 Oct 14 09:10 commons-jxpath-1.3.jar
-rw-r--r--    1 505      501       1681848 Oct 14 09:10 commons-jxpath-1.3-javadoc.jar
-rw-r--r--    1 505      501       7403118 Oct 14 09:10 commons-jxpath-1.3-sources.jar
226 Directory send OK.
ftp> lcd ~/cmdline/
Local directory now /home/huey/cmdline
ftp> get commons-jxpath-1.3.jar
local: commons-jxpath-1.3.jar remote: commons-jxpath-1.3.jar
227 Entering Passive Mode (10,1,231,4,92,222).
150 Opening BINARY mode data connection for commons-jxpath-1.3.jar (2738534 bytes).
226 Transfer complete.
2738534 bytes received in 0.0679 secs (40334.24 Kbytes/sec)
ftp> bye
221 Goodbye.

 

推荐阅读