码迷,mamicode.com
首页 > 其他好文 > 详细

Centos下ftp协议连接远程ftp server主机

时间:2018-12-19 13:10:54      阅读:1409      评论:0      收藏:0      [点我收藏+]

标签:cat   local   open   div   receive   connected   warning   ppi   状态   

环境说明

[root@Check3 ~]# cat /etc/redhat-release 
CentOS release 6.9 (Final)
[root@Check3 ~]# uname -a
Linux Check3 2.6.32-696.16.1.el6.x86_64 #1 SMP Wed Nov 15 16:51:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

FTP客户端安装

[root@Check3 ~]# yum -y install ftp

连接远程ftp server

格式fit IP 端口

[root@Check3 ~]# ftp 192.168.1.10 22
Connected to 192.168.1.10 (192.168.1.10).
220-#####################################################
220-FileZilla Server version 0.9.46 beta
220-Welcome To Elements FTP
220 #####################################################
Name (192.168.1.10:root): Admin
331 Password required for admin
Password:
230 Logged on
Remote system type is UNIX.

命令参数

显示当前FTP连接状态

ftp> status
Connected to 192.168.1.10.
No proxy connection.
Mode: stream; Type: ascii; Form: non-print; Structure: file
Verbose: on; Bell: off; Prompting: on; Globbing: on
Store unique: off; Receive unique: off
Case: off; CR stripping: on
Ntrans: off
Nmap: off
Hash mark printing: off; Use of PORT cmds: on
Tick counter printing: off

显示远程主机系统类型

ftp> system
215 UNIX emulated by FileZilla

列出当前目录下的文件或目录

dir 等同于 ls

ftp> dir
227 Entering Passive Mode (192.168.1.10,80,7)
150 Opening data channel for directory listing of "/"
drwxr-xr-x 1 ftp ftp 0 Oct 19 2018 WCY
drwxr-xr-x 1 ftp ftp 0 Aug 21 2018 ***
drwxr-xr-x 1 ftp ftp 0 Dec 10 10:40 ***
drwxr-xr-x 1 ftp ftp 0 Dec 03 13:29 ***
drwxr-xr-x 1 ftp ftp 0 Nov 01 2018 ***
drwxr-xr-x 1 ftp ftp 0 Nov 19 16:38 ***
drwxr-xr-x 1 ftp ftp 0 Dec 12 17:47 ***
drwxr-xr-x 1 ftp ftp 0 Nov 21 10:34 ***
226 Successfully transferred "/"

ftp> ls
227 Entering Passive Mode (192.168.1.10,80,9)
150 Opening data channel for directory listing of "/"
drwxr-xr-x 1 ftp ftp 0 Oct 19 2018 WCY
drwxr-xr-x 1 ftp ftp 0 Aug 21 2018 ***
drwxr-xr-x 1 ftp ftp 0 Dec 10 10:40 ***
drwxr-xr-x 1 ftp ftp 0 Dec 03 13:29 ***
drwxr-xr-x 1 ftp ftp 0 Nov 01 2018 ***
drwxr-xr-x 1 ftp ftp 0 Nov 19 16:38 ***
drwxr-xr-x 1 ftp ftp 0 Dec 12 17:47 ***
drwxr-xr-x 1 ftp ftp 0 Nov 21 10:34 ***
226 Successfully transferred "/"

列出当前所在远程FTP路径

ftp> cd WCY
250 CWD successful. "/WCY" is current directory.
ftp> pwd
257 "/WCY" is current directory.

在远程主机中创建目录

ftp> mkdir test
257 "/WCY/test" created successfully
ftp> ls
227 Entering Passive Mode (192.168.1.10,80,12)
150 Opening data channel for directory listing of "/WCY"
drwxr-xr-x 1 ftp ftp 0 Dec 19 10:57 test
226 Successfully transferred "/WCY"

删除远程主机中的目录

ftp> rmdir test
250 Directory deleted successfully
ftp> ls
227 Entering Passive Mode (192.168.1.10,80,13)
150 Opening data channel for directory listing of "/WCY"
226 Successfully transferred "/WCY"

返回上一级

cdup  或 cd ..

改变远程主机文件权限

chmod  权限  文件

将本地一个文件传送至远程主机中

等价命令send

ftp> put /root/test.wcy /WCY/test.wcy
local: /root/test.wcy remote: /WCY/test.wcy
227 Entering Passive Mode (192.168.1.10,80,16)
150 Opening data channel for file upload to server of "/WCY/test.wcy"
226 Successfully transferred "/WCY/test.wcy"
21 bytes sent in 3.3e-05 secs (636.36 Kbytes/sec)
ftp> cd /WCY
250 CWD successful. "/WCY" is current directory.
ftp> ls
227 Entering Passive Mode (192.168.1.10,80,17)
150 Opening data channel for directory listing of "/WCY"
-rw-r--r-- 1 ftp ftp 21 Dec 19 11:03 test.wcy
226 Successfully transferred "/WCY"

将本地主机中一批文件传送至远程主机

mput local-files

删除远程主机中的文件

ftp> ls
227 Entering Passive Mode (192.168.1.10,80,34)
150 Opening data channel for directory listing of "/WCY"
-rw-r--r-- 1 ftp ftp 243456000 Oct 19 2018 MySQL-5.6.41-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 ftp ftp 21 Dec 19 11:03 test.wcy
226 Successfully transferred "/WCY"
ftp> delet MySQL-5.6.41-1.el7.x86_64.rpm-bundle.tar
250 File deleted successfully
ftp> ls
227 Entering Passive Mode (192.168.1.10,80,35)
150 Opening data channel for directory listing of "/WCY"
-rw-r--r-- 1 ftp ftp 21 Dec 19 11:03 test.wcy
226 Successfully transferred "/WCY"

删除远程上的一批文件

mdelete [remote-files]

将文件从远程主机上下载到本地主机中

等价命令recv

ftp> pwd
257 "/通用文件/linux/mysql" is current directory.
ftp> get /通用文件/linux/mysql/perl-5.10.0.tar.gz /root/perl-5.10.0.tar.gz
local: /root/perl-5.10.0.tar.gz remote: /通用文件/linux/mysql/perl-5.10.0.tar.gz
227 Entering Passive Mode (192.168.1.10,80,56)
150 Opening data channel for file download from server of "/通用文件/linux/mysql/perl-5.10.0.tar.gz"
WARNING! 56500 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 Successfully transferred "/通用文件/linux/mysql/perl-5.10.0.tar.gz"
15595020 bytes received in 0.33 secs (47322.31 Kbytes/sec)

从远程主机上下载一批文件到本地主机

mget [remote-files]

退出

ftp> bye
221 Goodbye

内容整理至网络,如遇不懂的请自行baidu

Centos下ftp协议连接远程ftp server主机

标签:cat   local   open   div   receive   connected   warning   ppi   状态   

原文地址:https://www.cnblogs.com/LuckWJL/p/10142199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!