原文:https://www.cnblogs.com/tssc/p/9593614.html

1.登陆ftp服务器

ftp [IP] [PORT]        # 登陆ftp服务器,本机登陆可以不写IP
实例演示:
[root@ftpsrv vsftpd]# ftp 127.0.0.1 21
Connected to 127.0.0.1 (127.0.0.1).
(vsFTPd 2.2.2)
Name (127.0.0.1:root): nice
Please specify the password.
Password:
Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

  可以看出登陆后默认为二进制传输模式

2.ftp子命令

2.1.帮助命令

ftp> ?|help                  # 显示ftp内部命令的帮助信息

2.2.查看ftp中的文件列表(ls和dir都可以查看)

ftp> dir
Entering Passive Mode (127,0,0,1,44,241).
Here comes the directory listing.
drwxr-xr-x 2 501 501 4096 Sep 04 07:18 aaa
drwxr-xr-x 2 501 501 4096 Sep 05 08:59 bbb
Directory send OK.
ftp> ls
Entering Passive Mode (127,0,0,1,71,215).
Here comes the directory listing.
drwxr-xr-x 2 501 501 4096 Sep 04 07:18 aaa
drwxr-xr-x 2 501 501 4096 Sep 05 08:59 bbb
Directory send OK.
ftp>

2.3.切换ftp的目录

ftp> cd aaa      # 切换到ftp的aaa目录
Directory successfully changed.
ftp> pwd        # 查看当前所在的ftp目录
"/aaa"
ftp> ls
Entering Passive Mode (127,0,0,1,88,202).
Here comes the directory listing.
-rw-r--r-- 1 501 501 0 Sep 05 09:01 aaa1
-rw-r--r-- 1 501 501 0 Sep 05 09:02 aaa2
Directory send OK.
ftp>

2.4.查询linux系统信息

1) 查询系统中的文件列表

ftp> ! [linux系统命令]          # 在ftp服务器中执行系统命令,之后回到ftp环境中

  

ftp> ! ls /usr/local/
aegis bin cloudmonitor etc games include lib lib64 libexec logs nginx sbin share src

2)切换linux中的工作目录

ftp> lcd /tmp/            # 在ftp服务器中切换本地工作目录(登陆ftp前的系统中的目录),可以tab补全
Local directory now /tmp

2.5.下载上传文件或目录

1)创建和删除ftp目录

ftp> mkdir ccc
"/aaa/ccc" created
ftp> ls
Entering Passive Mode (127,0,0,1,194,152).
Here comes the directory listing.
-rw-r--r-- 1 501 501 0 Sep 05 09:01 aaa1
-rw-r--r-- 1 501 501 0 Sep 05 09:02 aaa2
drwxr-xr-x 2 501 501 4096 Sep 05 09:06 ccc
Directory send OK.
ftp> rmdir ccc
Remove directory operation successful.
ftp> ls
Entering Passive Mode (127,0,0,1,214,114).
Here comes the directory listing.
-rw-r--r-- 1 501 501 0 Sep 05 09:01 aaa1
-rw-r--r-- 1 501 501 0 Sep 05 09:02 aaa2
Directory send OK.

2)下载ftp的文件

# 下载单个文件

ftp> !pwd        # 查看当前所在的系统工作目录
/tmp
ftp> ls
Entering Passive Mode (127,0,0,1,223,180).
Here comes the directory listing.
-rw-r--r-- 1 501 501 0 Sep 05 09:01 aaa1
-rw-r--r-- 1 501 501 0 Sep 05 09:02 aaa2
Directory send OK.
ftp> get aaa1    # 下载aaa1文件
local: aaa1 remote: aaa1
Entering Passive Mode (127,0,0,1,33,232).
Opening BINARY mode data connection for aaa1 (0 bytes).
Transfer complete.
ftp> !ls
aaa1
ftp> get aaa2 aaa3    # 下载aaa2文件,并命名为aaa3
local: aaa3 remote: aaa2
Entering Passive Mode (127,0,0,1,171,86).
Opening BINARY mode data connection for aaa2 (0 bytes).
Transfer complete.
ftp> !ls          # 查看,下载成功
aaa1 aaa3

  # 下载多个文件

ftp> mget aaa1 aaa2
mget aaa1? y
Entering Passive Mode (127,0,0,1,83,114).
Opening BINARY mode data connection for aaa1 (0 bytes).
Transfer complete.
mget aaa2? y
Entering Passive Mode (127,0,0,1,217,121).
Opening BINARY mode data connection for aaa2 (0 bytes).
Transfer complete.
ftp> !ls -l
total 1532
-rw-r--r-- 1 root root 0 Sep 5 17:20 aaa1    # 可以看到文件创建时间已经更改
-rw-r--r-- 1 root root 0 Sep 5 17:20 aaa2
-rw-r--r-- 1 root root 0 Sep 5 17:14 aaa3

3)上传文件

# 上传单个文件

# 创建测试文件

[root@ftpsrv tmp]# touch ddd1
[root@ftpsrv tmp]# touch ddd2
[root@ftpsrv tmp]# ll
total 1532
-rw-r--r-- 1 root root 0 Sep 5 17:20 aaa1
-rw-r--r-- 1 root root 0 Sep 5 17:20 aaa2
-rw-r--r-- 1 root root 0 Sep 5 17:14 aaa3
-rw-r--r-- 1 root root 0 Sep 5 17:23 ddd1
-rw-r--r-- 1 root root 0 Sep 5 17:23 ddd2

# 上传

ftp> put ddd1       # 上传单个文件,可以tab补全
local: ddd1 remote: ddd1
Entering Passive Mode (127,0,0,1,69,10).
Ok to send data.
Transfer complete.
ftp> put ddd1 eee1    # 上传单个文件并改名
local: ddd1 remote: eee1
Entering Passive Mode (127,0,0,1,243,160).
Ok to send data.
Transfer complete.
ftp> ls
Entering Passive Mode (127,0,0,1,234,62).
Here comes the directory listing.
-rw-r--r-- 1 501 501 0 Sep 05 09:01 aaa1
-rw-r--r-- 1 501 501 0 Sep 05 09:02 aaa2
drwxr-xr-x 2 501 501 4096 Sep 05 09:18 bbb
-rw-r--r-- 1 501 501 0 Sep 05 09:23 ddd1
-rw-r--r-- 1 501 501 0 Sep 05 09:23 eee1
Directory send OK

# 上传多个文件

ftp> mput ddd1 ddd2
mput ddd1? y
Entering Passive Mode (127,0,0,1,92,11).
Ok to send data.
Transfer complete.
mput ddd2? y
Entering Passive Mode (127,0,0,1,66,108).
Ok to send data.
Transfer complete.
ftp> ls
Entering Passive Mode (127,0,0,1,191,91).
Here comes the directory listing.
-rw-r--r-- 1 501 501 0 Sep 05 09:01 aaa1
-rw-r--r-- 1 501 501 0 Sep 05 09:02 aaa2
drwxr-xr-x 2 501 501 4096 Sep 05 09:18 bbb
-rw-r--r-- 1 501 501 0 Sep 05 09:27 ddd1    # 查看修改时间可以确认已经上传成功
-rw-r--r-- 1 501 501 0 Sep 05 09:27 ddd2
-rw-r--r-- 1 501 501 0 Sep 05 09:23 eee1
Directory send OK.

2.6.ftp文件目录操作

1)修改ftp文件名

ftp> rename aaa1 qqq1
Ready for RNTO.
Rename successful.
ftp> ls
Entering Passive Mode (127,0,0,1,29,54).
Here comes the directory listing.
-rw-r--r-- 1 501 501 0 Sep 05 17:02 aaa2
drwxr-xr-x 2 501 501 4096 Sep 05 17:18 bbb
-rw-r--r-- 1 501 501 0 Sep 05 17:27 ddd1
-rw-r--r-- 1 501 501 0 Sep 05 17:27 ddd2
-rw-r--r-- 1 501 501 0 Sep 05 17:23 eee1
-rw-r--r-- 1 501 501 0 Sep 05 17:37 fff
-rw-r--r-- 1 501 501 0 Sep 05 17:01 qqq1    # 修改后的文件名
Directory send OK.

2)删除ftp文件

ftp> delete aaa2    # 删除aaa2文件
Delete operation successful.
ftp> ls
Entering Passive Mode (127,0,0,1,138,61).
Here comes the directory listing.
drwxr-xr-x 2 501 501 4096 Sep 05 17:18 bbb
-rw-r--r-- 1 501 501 0 Sep 05 17:27 ddd1
-rw-r--r-- 1 501 501 0 Sep 05 17:27 ddd2
-rw-r--r-- 1 501 501 0 Sep 05 17:23 eee1
-rw-r--r-- 1 501 501 0 Sep 05 17:37 fff
-rw-r--r-- 1 501 501 0 Sep 05 17:01 qqq1
Directory send OK.

 # 删除多个ftp文件

ftp> mdelete ddd1 ddd2 eee1
mdelete ddd1? y
Delete operation successful.
mdelete ddd2? y
Delete operation successful.
mdelete eee1? y
Delete operation successful.
ftp> ls
Entering Passive Mode (127,0,0,1,166,205).
Here comes the directory listing.
drwxr-xr-x 2 501 501 4096 Sep 05 17:18 bbb
-rw-r--r-- 1 501 501 0 Sep 05 17:37 fff
-rw-r--r-- 1 501 501 0 Sep 05 17:01 qqq1
Directory send OK.

3)删除ftp目录

ftp> rmdir bbb    # 删除bbb目录
Remove directory operation successful.
ftp> ls
Entering Passive Mode (127,0,0,1,143,198).
Here comes the directory listing.
-rw-r--r-- 1 501 501 0 Sep 05 17:37 fff
-rw-r--r-- 1 501 501 0 Sep 05 17:01 qqq1
Directory send OK.

2.7.其他ftp命令

1)切换传输模式

ftp> ascii        # 切换为ascii模式
200 Switching to ASCII mode.
ftp> bin        # 切换为二进制模式,默认登陆就是二进制传输模式
200 Switching to Binary mode.

2)关闭和重连ftp

ftp> close      # 断开ftp的连接
Goodbye.
ftp> ls        # 可以看出,无法显示ftp服务器的文件列表
Not connected.
ftp> open 127.0.0.1 21    # 重新连接ftp服务器
Connected to 127.0.0.1 (127.0.0.1).
(vsFTPd 2.2.2)
Name (127.0.0.1:root): admin     # 使用admin登陆ftp
Please specify the password.
Password:
Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls        # 可以再次查看ftp服务器的文件列表
Entering Passive Mode (127,0,0,1,227,247).
Here comes the directory listing.
drwxr-xr-x 2 501 501 4096 Sep 05 17:47 aaa
drwxr-xr-x 2 501 501 4096 Sep 05 16:59 bbb
Directory send OK.

3) 退出ftp会话

ftp> quit    # 也可以使用bye和exit
221 Goodbye.
[root@ftpsrv vsftpd]#

  

  

  

  

 

  

  

  

  

  

  

  

  

  

  

ftp操作命令的更多相关文章

  1. Linux下常用的ftp操作命令

    Linux下常用的ftp操作命令 =========== 完美的分割线 ============= 1.登陆ftp服务器 ftp [IP] [PORT] # 登陆ftp服务器,本机登陆可以不写IP 实 ...

  2. 基于多线程多用户的FTP服务器与客户端功能实现

    项目介绍: 用户加密认证 允许同时多用户登录 每个用户有自己的家目录 ,且只能访问自己的家目录 对用户进行磁盘配额,每个用户的可用空间不同 允许用户在ftp server上随意切换目录 允许用户查看当 ...

  3. CentOS7上安装FTP服务

    ---------------------------------------------------------------------------------------------------- ...

  4. 【ABAP系列】SAP ABAP 实现FTP的文件上传与下载

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 实现FTP的文 ...

  5. 常用DOS命令之通俗易懂篇

    目录 常用DOS命令之通俗易懂篇 Arp 命令 Assoc 关联 At 计划服务 Attrib 属性 Cd=chdir 目录 Cipher Cls 清屏 Color 颜色 Comp 比较 Compac ...

  6. ftp软件中保持连接命令CWD、PWD、LIST、NOOP四个操作命令解析

    转自:http://www.aspjzy.com/A/148.html 各位站长都知道,我们在维护网站的时候,经常需要一直保持ftp连接状态,这个时候在很多ftp客户端软件中都有一个保持全局连接的选项 ...

  7. Linux基本操作命令

    Linux基本操作命令 首先介绍一个名词“控制台(console)”,它就是我们通常见到的使用字符操作界面的人机接口,例如dos.我们说控制台命令,就是指通过字符界面输入的可以操作系统的命令,例如do ...

  8. ftp应用

    ftp的基本应用: 下载easyfzs ftp,仿真模拟ftp服务器. 类库: using System; using System.Collections.Generic; using System ...

  9. Ftp类

    using System; using System.Collections.Generic; using System.Text; using System.Net; using System.IO ...

随机推荐

  1. dbcp_c3p0连接mysql8.0.13

    背景 学习数据库的使用,上次没有记录,现在都回忆不起来了,所以这次重新学的时候顺便记录下. 配置环境 win10 jdk11 idea mysql8.0.13 DBCP连接使用 用配置文件目前我连接不 ...

  2. 浅谈Min_25筛(一看就懂的那种)

    作用 前提:一个积性函数\(F(i)\),要求\(F(P^k),P\in prime\)可以快速计算 实现\(O(\frac{n^{\frac{3}{4}}}{logn})\):\(\sum\limi ...

  3. Android Studio如何删除一个Module

    当你想在Android Studio中删除某个module时,大家习惯性的做法都是选中要删除的module,右键去找delete.但是在Android  Studio中你选中module,右键会发现没 ...

  4. 第六章、Linux 的档案权限不目彔配置

    1. 使用者不群组 2. Linux 档案权限概念 2.1 Linux 文件属怅 2.2 如何改变文件属怅不权限: chgrp, chown, chmod 2.3 目彔不档案乀权限意丿 2.4 Lin ...

  5. “可恶”的mariadb

    这是头一次用mariadb,听说是centos7自带的,本来本地用的好好地,今天想连接一下远程centos7主机上的mariadb,结果各种出错,痛不欲生,最后实在买办法只能卸载装mysql啦.稍微记 ...

  6. oracle之nvl,nvl2,decode

    oracle sql常用查询nvl,nvl2,decode区别及使用方法 1,NVL( E1, E2) 如果E1为NULL,则NVL函数返回E2的值,否则返回E1的值,如果两个参数都为NULL ,则返 ...

  7. 定时检查SetUID 权限文件列表的脚本文件

    [root@localhost ~]# find / -perm -4000 -o -perm -2000 > /root/suid.list #-perm安装权限査找.-4000对应的是Set ...

  8. DELPHI解析JSON格式化的日期

    DELPHI解析JSON格式化的日期 json返回的日期是 /Date(1560355200000)/ 这样的格式. 这个1560355200000,是指1970年以后的秒数. DELPHI如何解析这 ...

  9. 在从myql服务器上 取消主从关系和重新构建主从关系

    取消主从关系 mysql -uroot -p mysql>show slave status\G; 查看主库是否为之前的ip mysql>change master to master_h ...

  10. alpha测试和beta测试的区别是什么?

    1.测试时间不同: Beta测试是软件产品完成了功能测试和系统测试之后,在产品发布之前所进行的软件测试活动,它是技术测试的最后一个阶段. alpha测试简称“α测试”,可以从软件产品编码结束之时开始, ...