Contos 7 使用 Lftp 客户端来管理 ftp服务器

苏苏 苏苏
4873
2019-11-20


苏苏购买了 online 的 3 欧服务器后,online 还给了 100G 的 ftp 空间给苏苏做备份。自然要好好利用这 100G 了,苏苏打算用来给其他 VPS 备份。于是有了这篇教程。

本教程分四部分,分别如下

1 Lftp 介绍

2 安装 Lftp

3 Lftp 常用命令

4 Lftp 使用举例


一 Lftp 介绍

lftp命令是一款优秀的文件客户端程序,它支持ftp、SETP、HTTP和FTPs等多种文件传输协议(其中ftps和https需要在编译的时候包含openssl库)。lftp支持tab自动补全,记不得命令双击tab键,就可以看到可能的选项了。允许多个后台任务执行等功能,使用起来非常方便。它还有书签、排队、镜像、断点续传、多进程下载等功能。


二 安装 Lftp 

centos 7 运行一行命令就够了

yum -y install lftp


安装完后,就可以用 lftp 去登陆 ftp 服务器了,大概有下面几个方法

lftp ftp://user:password@site:port

lftp user:password@site:port

lftp site -p port -u user,password

lftp site:port -u user,password

上面几个密码都是明文的,所以苏苏一般会建议你使用下面的方法:

lftp 用户名@ftp地址:端口 

Password: # 在这里输入你的密码

这里说明一下,如果你的用户名有 @ 这个字符,要用 %40 来代替。


三 lftp 常用命令

登陆了 ftp 服务器后,就可以使用下面这些命令了

ls:显示远端文件列表

cd:切换远端目录

mget :下载远端文件(可以用通配符也就是 *)

pget :使用多个线程来下载远端文件, 预设为五个

mirror: 下载/上传(mirror -R)/同步 整个目录

put :上传文件

mput:上传多个文件(可以用通配符也就是 *)

mv: 移动远端文件

rm :删除远端文件。参数-r,递归删除文件夹

mrm: 删除多个远端文件(可以用通配符也就是 *)

mkdir: 建立远端目录

rmdir :删除远端目录。只能删除空的目录 如果要删除的非空的目录的话采用 rm -r  

pwd :显示目前远端所在目录

du :计算远端目录的大小

set net:limit-rate 10000,10000 限制上传下载各为10KB/s

set ftp:charset gbk 设置远程ftp site用gbk编码! 

lcd :切换本地目录

!ls 显示本地文件列表

lpwd: 显示本地目录

quit:退出ftp


四 Lftp 使用举例

#登陆 ftp 服务器

lftp sd-***@******.online.net

Password: # password of the user

lftp sd-***t@******.online.net:~>


#显示 ftp 服务器的所在的目录地址

pwd 

ftp://***@***.online.net


#显示 本地 所在的目录地址

!pwd

/root


# 显示 FTP 当前目录的文件

ls -al

drwxr-xr-x 2 1001 ftp 4096 Nov 18 01:41 .

drwxr-xr-x 2 1001 ftp 4096 Nov 18 01:41 ..

-rw------- 1 1001 ftp 4 Nov 19 21:03 .ftpquota


#显示 本地 当前目录的文件

!ls

susu.txt


#将本地的 susu.txt 传到 ftp 

put susu.txt

lftp sd-160973@dedibackup-dc3.online.net:/> ls -al

drwxr-xr-x 2 1001 ftp 4096 Nov 20 07:34 .

drwxr-xr-x 2 1001 ftp 4096 Nov 20 07:34 ..

-rw------- 1 1001 ftp 4 Nov 20 07:34 .ftpquota

-rw-r--r-- 1 1001 ftp 0 Nov 20 07:05 susu.txt


#断开 ftp

quit


更多的使用教程,大家参考第三步,慢慢学习吧。

这里,苏苏找到一个非常全的教程,大家可以直接参考

# 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


特别申明: 若无说明,文章均为原创,转载时请注明本文地址,谢谢合作!

本站仅为分享信息,绝对不是推荐,所有内容均仅代表个人观点,读者购买风险自担。如果你非要把风险推苏苏头上,不要这么残忍,好吗?
本站保证在法律范围内您的个人信息不经由本站透露给任何第三方。
所有网络产品均无法保证在中国任何地区,任何时间,任何宽带均有相同的访问体验,那种号称某机房绝不抽风的不是骗子就是呵呵.
任何IDC都有倒闭和跑路的可能,备份永远是最佳选择,服务器也是机器,不勤备份是对自己极不负责的表现.

加入群1:569839985

欢迎IDC提交优惠信息或者测试样机,提交信息请Eamil至admin#138vps.com,苏苏不保证一定会进行发布。

但请IDC留意以下内容:
无官方正式首页、无可用联络方式暂不发布;
曾经有过倒闭和跑路经历者重开不到6个月不做发布;
从本日起(2016-07-18)不接受任何形式的免费赞助和VPS馈赠,不接受任何评测报告的投稿,不接受任何付费发布和付费删除评论,所有IDC若有必要提交测试样机,请在7日后自行删除。
公告
欢迎加入qq群:569839985
本站诚换友情链接。在您的网站加上本站的友情链接后发邮件到 admin#138vps.com, 苏苏会自行审核,一周内会上线您的友情链接。
要求:建站一年以上,百度权重1,收录数量不低于一千。
请尽量使用 PayPal 进行交易,PayPal 对资金的保护政策更照顾买家。
年度爆文