zoukankan      html  css  js  c++  java
  • How to use FTP

    Forward from: https://www.server-world.info/en/note?os=CentOS_7&p=ftp&f=2

    Thanks for your share!

    [1] Install FTP Client.
    [root@dlp ~]# 
    yum -y install lftp
    [2] The connection with root account is prohibited by default, so access with an common user to FTP Server.
    # lftp [option] [hostname]

    [redhat@dlp ~]$ 
    lftp -u cent www.srv.world 

    Password:     
    # password of the user

    lftp cent@www.srv.world:~>
    # show current directory on FTP server

    lftp cent@www.srv.world:~> 
    pwd

    ftp://cent@www.srv.world
    # show current directory on local server

    lftp cent@www.srv.world:~> 
    !pwd

    /home/redhat
    # show files in current directory on FTP server

    lftp cent@www.srv.world:~> 
    ls

    drwxr-xr-x    2 1000     1000           23 Jul 19 01:33 public_html
    -rw-r--r--    1 1000     1000          399 Jul 20 16:32 test.py
    
    # show files in current directory on local server

    lftp cent@www.srv.world:~> 
    !ls -l

    total 12
    -rw-rw-r-- 1 redhat redhat 10 Jul 20 14:30 redhat.txt
    -rw-rw-r-- 1 redhat redhat 10 Jul 20 14:59 test2.txt
    -rw-rw-r-- 1 redhat redhat 10 Jul 20 14:59 test.txt
    
    # change directory

    lftp cent@www.srv.world:~> 
    cd public_html

    lftp cent@www.srv.world:~/public_html> 
    pwd

    ftp://cent@www.srv.world/%2Fhome/cent/public_html
    # upload a file to FTP server

    # "-a" means ascii mode ( default is binary mode )

    lftp cent@www.srv.world:~> 
    put -a redhat.txt

    22 bytes transferred
    Total 2 files transferred
    lftp cent@www.srv.world:~> 
    ls

    drwxr-xr-x    2 1000     1000           23 Jul 19 01:33 public_html
    -rw-r--r--    1 1000     1000           10 Jul 20 17:01 redhat.txt
    -rw-r--r--    1 1000     1000          399 Jul 20 16:32 test.py
    -rw-r--r--    1 1000     1000           10 Jul 20 17:01 test.txt
    
    # upload some files to FTP server

    lftp cent@www.srv.world:~> 
    mput -a test.txt test2.txt

    22 bytes transferred
    Total 2 files transferred
    lftp cent@www.srv.world:~> 
    ls

    drwxr-xr-x    2 1000     1000           23 Jul 19 01:33 public_html
    -rw-r--r--    1 1000     1000          399 Jul 20 16:32 test.py
    -rw-r--r--    1 1000     1000           10 Jul 20 17:06 test.txt
    -rw-r--r--    1 1000     1000           10 Jul 20 17:06 test2.txt
    
    # download a file from FTP server

    # "-a" means ascii mode ( default is binary mode )

    lftp cent@www.srv.world:~> 
    get -a test.py

    416 bytes transferred
    # download some files from FTP server

    lftp cent@www.srv.world:~> 
    mget -a test.txt test2.txt

    20 bytes transferred
    Total 2 files transferred
    # create a directory in current directory on FTP Server

    lftp cent@www.srv.world:~> 
    mkdir testdir

    mkdir ok, `testdir' created
    lftp cent@www.srv.world:~> 
    ls

    drwxr-xr-x    2 1000     1000           23 Jul 19 01:33 public_html
    -rw-r--r--    1 1000     1000          399 Jul 20 16:32 test.py
    -rw-r--r--    1 1000     1000           10 Jul 20 17:06 test.txt
    -rw-r--r--    1 1000     1000           10 Jul 20 17:06 test2.txt
    drwxr-xr-x    2 1000     1000            6 Jul 20 17:16 testdir
    226 Directory send OK.
    
    # delete a direcroty in current directory on FTP Server

    lftp cent@www.srv.world:~> 
    rmdir testdir

    rmdir ok, `testdir' removed
    lftp cent@www.srv.world:~> 
    ls

    drwxr-xr-x    2 1000     1000           23 Jul 19 01:33 public_html
    -rw-r--r--    1 1000     1000          399 Jul 20 16:32 test.py
    -rw-r--r--    1 1000     1000           10 Jul 20 17:06 test.txt
    -rw-r--r--    1 1000     1000           10 Jul 20 17:06 test2.txt
    
    # delete a file in current directory on FTP Server

    lftp cent@www.srv.world:~> 
    rm test2.txt

    rm ok, `test2.txt' removed
    lftp cent@www.srv.world:~> 
    ls

    drwxr-xr-x    2 1000     1000           23 Jul 19 01:33 public_html
    -rw-r--r--    1 1000     1000          399 Jul 20 16:32 test.py
    -rw-r--r--    1 1000     1000           10 Jul 20 17:06 test.txt
    
    # delete some files in current directory on FTP Server

    lftp cent@www.srv.world:~> 
    mrm redhat.txt test.txt

    rm ok, 2 files removed
    lftp cent@www.srv.world:~> 
    ls

    drwxr-xr-x    2 1000     1000           23 Jul 19 01:33 public_html
    
    # execute commands with "![command]"

    lftp cent@www.srv.world:~> 
    !cat /etc/passwd

    root:x:0:0:root:/root:/bin/bash
    bin:x:1:1:bin:/bin:/sbin/nologin
    ...
    ...
    redhat:x:1001:1001::/home/redhat:/bin/bash
    
    # exit

    lftp cent@www.srv.world:~> 
    quit

    221 Goodbye.
  • 相关阅读:
    「移动开发云端新模式探索实践」征文活动
    为数据赋能:腾讯TDSQL分布式金融级数据库前沿技术
    腾讯刘金明:腾讯云 EB 级对象存储架构深度剖析及实践
    腾讯冯宇彦:基于大数据与人工智能的智慧交通云
    腾讯毛华:智能交互,AI助力下的新生态
    腾讯聂晶:数据资产助力企业发展
    2018云+未来峰会圆桌面对面:以网络安全之能,造国之重器
    全景解析腾讯云安全:从八大领域输出全链路智慧安全能力
    为 “超级大脑”构建支撑能力,腾讯云聚焦AI技术落地
    web service介绍
  • 原文地址:https://www.cnblogs.com/zwingblog/p/6043633.html
Copyright © 2011-2022 走看看