The ftp command solves the upload and download of files

How to use the ftp command in Linux, including how to connect to the ftp server, upload or download files, and create folders. Although there are many ftp desktop applications (such as FlashFXP), it is still necessary to master the use of command line ftp in servers, SSH, and remote sessions.

1.ftp command  

使用格式:ftp [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [computer]

    -v:禁止显示远程服务器响应信息

    -n:禁止自动登录

    -i:多文件传输过程中关闭交互提示

    -d:启用调试,显示所有客户端与服务器端传递的命令

    -g:禁用文件名通配符,允许在本地文件和路径名中使用

  实例:ftp 192.168.122.12

  输入用户名、密码,即可完成登录。

2. Directory operations

  FTP commands can list, move, and create folders.

  • ls - print directory listing
  • !ls - View local directories
  • cd - change directory
  • mkdir - create folder

3. Use FTP to download files

  Before downloading a file, you first need to use the lcd command to set the location of the local receiving directory.

  • lcd - specify download directory
  • get file.txt [file_new.txt] - download file support to change the name
  • mget *.txt - Use mget + wildcard to download multiple files

4. Use FTP to upload files

  • put file.txt [file_new.txt] - upload file support to change the name
  • put /home/data/cwh/file.txt - absolute path
  • mput *.txt - upload multiple files

5. Close the FTP connection

  After finishing the FTP work, the connection needs to be closed for safety. There are 3 commands to close the connection:

  • bye - close the connection
  • exit - close the connection
  • quit - close the connection
  • close - close the connection

6. Other commands

  • ? -- 查询ftp命令
    help -- 查询ftp命令
    open [ftp server name] -- 和指定的远程Linux FTP服务器连接
    user [user name] [password] -- 使用指定远程Linux FTP服务器的用户登录
    pwd -- 显示当前路径
    ls -- 列出目录和文件
    dir -- 列出目录和文件(同上)
    mkdir [foldname] -- 创建指定目录
    rmdir [foldname] -- 删除指定目录
    cd -- 切换目录
    delete [filename] -- 删除文件
    rename [filename] [newfilename] -- 重命名
    close -- 关闭连接 但保留FTP命令参数提示
    disconnect -- 关闭连接 但保留FTP命令参数提示(同上)
    bye -- 结束连接
    quit -- 结束连接
    ! -- 直接从远程Linux FTP进入到本地Shell中
    exit -- (接上步)从本地Shell环境返回远程Linux FTP中
    !ls -- 列出本地机器目录和文件
    lcd [foldname] -- 更改本地工作目录
    binary -- 使用二进制传输文件
    prompt -- 切换提示(使用mput或mget上传下载多个文件时避免提示)
    case -- 在使用mget时,将远程主机文件名的大写转换为小写字母
    cdup -- 进入远程主机目录的父目录
    system -- 显示远程主机的操作系统类型
    hash  -- 每传输1024字节,显示一个hash符号(#)
    status -- 显示当前ftp状态
    

     

7. Examples:

 “开始”→“运行”→输入“FTP”
  open 122.122.122.122 2222
  用户名
  密码
  查看目录
      -- dir 文件及目录
      -- ls 只查看文件
  mkdir xxx 新建目录
  cd xxx 切换目录
 binary 采用二进制传输
 lcd /home/data 定位本地目录
 !dir 查看本地目录及文件
 put xyz.txt 上传文件(mput)
 get xyz.txt 下载文件(mget)
 delete *.txt 删除文件
 cd.. 返回上一级
 rmdir xxx 删除空文件夹
 bye 退出ftp服务器
 pwd 查看当前目录

 

Guess you like

Origin blog.csdn.net/qq_27828675/article/details/102744164