Linux ftp命令使用详解
ftp命令是最常见的FTP协议的客户端, 它是FTP协议的用户接口,使用ftp命令可以方便的同远程主机传送文件。
用法
选项
选项 | 说明 |
---|
-A | Use active mode for data transfers. |
-p | Use passive mode for data transfers. |
-i | 关闭互动模式,不询问任何问题 |
-n | 不使用自动登录 |
-e | 关闭历史命令和命令编辑功能 |
-g | 关闭本地主机文件名称支持特殊字符的扩充特性; |
-v | 显示指令执行过程 |
-d | 详细显示指令执行过程,便于排错或分析程序执行的情况; |
参数
host:指定要连接的FTP服务器的主机名或ip地址。如果没有指定参数ftp则进入解释器交互模式。
ftp命令
- ! [command [args]] : 执行本机命令
- $ macro-name [args] : 执行由macdef命令定义的marco-name宏
- account [passwd] : 账户登录
- append local_file [remote-file] : 文件内容追加
- ascii : 设定以ASCII方式传送文件
- bell : 每完成一次文件传送,报警提示.
- binary : 设定以二进制方式传送文件
- bye : 终止主机FTP进程,并退出FTP管理方式.
- case : 当为ON时,用MGET命令拷贝的文件名到本地机器中,全部转换为小写字母.
- cd [dir] : 切换远程主机的目录
- cdup : 返回上一级目录
- chmod mode file-name : 改变远端主机的文件权限.
- close : 终止远端的FTP进程,返回到FTP命令状态,所有的宏定义都被删除
- cr: Toggle carriage return stripping during ascii type file retrieval.
- delete remote-file :删除远端主机中的文件
- debug [debug-value] : Toggle debugging mode.
- dir [remote-dir] [local-dir]: 列出当前远端主机目录中的文件.如果有本地文件,就将结果写至本地文件.
- form format : Set the file transfer form to format. The default format is “file”
- get remote-file [local-file] : 下载文件
- glob :Toggle filename expansion for mdelete, mget and mput.
- hash : Toggle hash-sign (#) printing for each data block trans‐ ferred. The size of a data block is 1024 bytes.
- help [command]: 显示命令帮助信息
- idle [seconds]: 设置远程主机的不活动的定时器
- lcd [dir] : 改变当前本地主机的工作目录,如果缺省,就转到当前用户的HOME目录
- ls [remote-directory] [local-file] : 同DIR
- macdef : 定义宏命令
- mdelete [remote-files] : 删除多个文件
- mdir remote-files local-file : 同 DIR
- mget remote-files : 从远端主机接收一批文件至本地主机.
- mkdir dir : 在远端主机中建立目录.
- mls remote-files local-file: 同 nlist
- mode [mode-name]: Set the file transfer mode to mode-name. The default mode is “stream” mode.
- modtime file-name : 显示远程主机文件的最后修改时间
- mput local-file: 批量上传文件
- newer file-name [local-file]: 仅在远程文件更新的情况下下载文件
- nlist [remote-file] [local-file]: 列出文件
- nmap [impattern outpattern]: Set or unset the filename mapping mechanism
- ntrans [inchars [outchars]]
- open host [port]: 打开远程主机
- prompt : Toggle interactive prompting.
- proxy ftp-command: Execute an ftp command on a secondary control connection.
- put local-file [remot-file]: 上传文件
- pwd : 显示远程主机的工作目录
- quit : 同bye
- quote arg1 arg2 … : The arguments specified are sent, verbatim, to the remote FTP server
- recv remote-file [local-file] # 同GET
实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| ftp> ascii ftp> bell ftp> binary ftp> bye ftp> case ftp> cd ftp> cdup ftp> chmod ftp> close ftp> delete ftp> dir [remote-directory] [local-file] ftp> get [remote-file] [local-file] ftp> help [command] ftp> lcd ftp> ls [remote-directory] [local-file] ftp> macdef ftp> mdelete [remote-files] ftp> mget [remote-files] ftp> mkdir directory-name ftp> mput local-files ftp> open host [port] ftp> prompt ftp> put local-file [remote-file] ftp> pwd ftp> quit ftp> recv remote-file [local-file] ftp> rename [from] [to] ftp> rmdir directory-name ftp> send local-file [remote-file] ftp> status ftp> system ftp> user user-name [password] [account] ftp> ? [command] ftp> !
|
关闭FTP连接
下载文件
1 2
| ftp> get readme.txt ftp> mget *.txt
|
上传文件
1 2
| ftp> put /path/to/readme.txt ftp> mput *.txt
|