lftp是一个支持下载,上传同时还有支持screen用法的工具,相当于ftp的客户端,有它支持访问文件的协议有: ftp, ftps, http, https, hftp, fish
1.登陆的方式:
lftp 用户名:密码@ip地址
[root@zhu2 ~]# lftp zhu:123456@192.168.70.137
lftp zhu@192.168.70.137:~> ls -l
drwxr-xr-x 9 500 500 4096 Sep 09 16:02 LVS
-rw-r–r– 1 500 500 0 Sep 09 15:52 txt1
lftp 用户名@ip地址
lftp 192.168.70.137:~> bye
[root@zhu2 ~]# lftp zhu@192.168.70.137
口令:
lftp zhu@192.168.70.137:~> ls -l
drwxr-xr-x 9 500 500 4096 Sep 09 16:02 LVS
-rw-r–r– 1 500 500 0 Sep 09 15:52 txt1
lftp ip地址 -p 端口号 -u 用户,密码
[root@zhu2 ~]# lftp 192.168.70.137 -u zhu,123456
lftp zhu@192.168.70.137:~>
lftp ip地址:端口 -u 用户,密码
[root@zhu2 ~]# lftp 192.168.70.137:21 -u zhu,123456
lftp zhu@192.168.70.137:~>
2.常用指令
help :查看文件列表
lftp zhu@192.168.70.137:~> help
!<shell-command> (commands)
alias [<name> [<value>]] anon
bookmark [SUBCMD] cache [SUBCMD]
cat [-b] <files> cd <rdir>
chmod [OPTS] mode file… close [-a]
[re]cls [opts] [path/][pattern] debug [<level>|off] [-o <file>]
du [options] <dirs> exit [<code>|bg]
get [OPTS] <rfile> [-o <lfile>] glob [OPTS] <cmd> <args>
help [<cmd>] history -w file|-r file|-c|-l [cnt]
jobs [-v] kill all|<job_no>
lcd <ldir> lftp [OPTS] <site>
ls [<args>] mget [OPTS] <files>
mirror [OPTS] [remote [local]] mkdir [-p] <dirs>
module name [args] more <files>
mput [OPTS] <files> mrm <files>
mv <file1> <file2> [re]nlist [<args>]
open [OPTS] <site> pget [OPTS] <rfile> [-o <lfile>]
put [OPTS] <lfile> [-o <rfile>] pwd [-p]
queue [OPTS] [<cmd>] quote <cmd>
repeat [OPTS] [delay] [command] rm [-r] [-f] <files>
rmdir [-f] <dirs> scache [<session_no>]
set [OPT] [<var> [<val>]] site <site_cmd>
source <file> user <user|URL> [<pass>]
version wait [<jobno>]
zcat <files> zmore <files>
lftp zhu@192.168.70.137:~>
ls :查看远程主机上的文件或目录
!ls:查看本地所在的目录下的文件列表
lftp zhu@192.168.70.137:~> ls
drwxr-xr-x 9 500 500 4096 Sep 09 16:02 LVS
-rw-r–r– 1 500 500 0 Sep 09 15:52 txt1
lftp zhu@192.168.70.137:~> !ls
iptables lnmp LVS
pwd :显示所在的远程主机上的目录
lpwd :显示的是本地的所在目录
lftp zhu@192.168.70.137:~> pwd
ftp://zhu:123456@192.168.70.137:21/%2Fhome/zhu
lftp zhu@192.168.70.137:~> lpwd
/root
cd :切换远程主机的目录
lcd:切换本地的目录
lftp zhu@192.168.70.137:~> pwd
ftp://zhu:123456@192.168.70.137:21/%2Fhome/zhu
lftp zhu@192.168.70.137:~> lpwd
/root
lftp zhu@192.168.70.137:~> cd lvs
lftp zhu@192.168.70.137:~/lvs> pwd
ftp://zhu:123456@192.168.70.137:21/%2Fhome/zhu/lvs
lftp zhu@192.168.70.137:~/lvs> lcd /root/iptables/
lcd 成功, 本地目录=/root/iptables
lftp zhu@192.168.70.137:~/lvs> lpwd
/root/iptables
get 文件名 :下载单个文件到本地所在的当前目录
lftp zhu@192.168.70.137:~> get txt1
lftp zhu@192.168.70.137:~> !ls
iptables lnmp LVS txt1
mget (支持通配符,可同时下载多个文件)
lftp zhu@192.168.70.137:~/lvs> mget auto*
3429843 bytes transferred
Total 2 files transferred
lftp zhu@192.168.70.137:~/lvs> !ls
autoconf-2.68.tar.gz automake-1.11.2.tar.gz iptables lnmp LVS txt1
put 文件名 :上传本地的某个文件到远程主机的当前所在目录
lftp zhu@192.168.70.137:~> put zabbix_sender.py
2764 bytes transferred
lftp zhu@192.168.70.137:~> ls -l
drwxr-xr-x 9 500 500 4096 Sep 09 16:02 lvs
-rw-r–r– 1 500 500 0 Sep 09 15:52 txt1
-rw-r–r– 1 500 500 2764 Sep 09 17:35 zabbix_sender.py
-rw-r–r– 1 0 0 0 Sep 09 17:32 zhujiangtao
drwxr-xr-x 2 0 0 4096 Sep 09 17:32 zhuzhu
mput :同时上传多个文件支持通配符
lftp zhu@192.168.70.137:~> mput check*
14908 bytes transferred
Total 2 files transferred
lftp zhu@192.168.70.137:~> ls -l
-rw-r–r– 1 500 500 585 Sep 09 17:35 checkSYSConfig.ini
-rw-r–r– 1 500 500 14323 Sep 09 17:35 checklastLoginAndipTables.py
drwxr-xr-x 9 500 500 4096 Sep 09 16:02 lvs
-rw-r–r– 1 500 500 2764 Sep 09 17:35 zabbix_sender.py
-rw-r–r– 1 0 0 0 Sep 09 17:32 zhujiangtao
drwxr-xr-x 2 0 0 4096 Sep 09 17:32 zhuzhu
get,put指令针对的是文件,
若要针对目录,可用到另一重要的指令。mirror
相关阅读:
Ubuntu上用LFTP和cRON实现每天自动备份到FTP服务器 http://www.linuxidc.com/Linux/2009-10/22063.htm
Linux lftp乱码解决 http://www.linuxidc.com/Linux/2008-09/15468.htm
Linux lftp乱码解决及使用书签的方法 http://www.linuxidc.com/Linux/2011-04/34367.htm
LFTP 的详细介绍:请点这里
LFTP 的下载地址:请点这里
更多详情见请继续阅读下一页的精彩内容:http://www.linuxidc.com/Linux/2013-09/90112p2.htm
3.mirror 指令的用法
mirror 目录名 :下载整个目录(包括该目录所包含的子目录)
lftp zhu@192.168.70.137:~> mirror lvs/
Total: 130 directories, 3401 files, 7 symlinks
New: 3401 files, 7 symlinks
69273581 bytes transferred in 25 seconds (2.65M/s)
lftp zhu@192.168.70.137:~> !ls lvs
7e3a82377fa8.tar.bz2 ClusterLabs-resource-agents-b735277 libnet-1.1.6
autoconf-2.68 glue-1.0.9.tar.bz2 libnet-1.1.6.tar.gz
autoconf-2.68.tar.gz Heartbeat-3-0-7e3a82377fa8 Reusable-Cluster-Components-glue–glue-1.0.9
automake-1.11.2 ipvsadm-1.24 v3.9.2
automake-1.11.2.tar.gz ipvsadm-1.24.tar.gz
mirror 远程目录 本地目录 :把远程目录下载到本地并重新命名
lftp zhu@192.168.70.137:~> mirror zhuzhu/ taotao
Total: 1 directory, 1 file, 0 symlinks
New: 1 file, 0 symlinks
lftp zhu@192.168.70.137:~> bye
[root@zhu2 ~]#
[root@zhu2 ~]# ll
总计 16
drwxr-xr-x 2 root root 4096 09-06 20:32 iptables
drwxr-xr-x 14 root root 4096 09-02 23:14 lnmp
drwxr-xr-x 9 root root 4096 09-03 23:34 LVS
drwxr-xr-x 2 root root 4096 09-09 05:38 taotao
mirror . :下载远程主机当前目录下的所有文件和目录
[root@zhu2 ~]# lftp 192.168.70.137 -u zhu,123456
lftp zhu@192.168.70.137:~> ls
-rw-r–r– 1 500 500 585 Sep 09 17:35 checkSYSConfig.ini
-rw-r–r– 1 500 500 14323 Sep 09 17:35 checklastLoginAndipTables.py
-rw-r–r– 1 500 500 2764 Sep 09 17:35 zabbix_sender.py
-rw-r–r– 1 500 500 0 Sep 09 17:32 zhujiangtao
drwxr-xr-x 2 500 500 4096 Sep 09 21:30 zhuzhu
lftp zhu@192.168.70.137:~> mirror .
Total: 2 directories, 5 files, 0 symlinks
New: 5 files, 0 symlinks
17672 bytes transferred
To be removed: 18 directories, 15 files, 0 symlinks
lftp zhu@192.168.70.137:~> !ls
checklastLoginAndipTables.py iptables LVS zhujiangtao
checkSYSConfig.ini lnmp zabbix_sender.py zhuzhu
mirror -R 本地目录 :上传整个目录
[root@zhu2 ~]# lftp 192.168.70.137 -u zhu,123456
lftp zhu@192.168.70.137:~> mirror -R iptables/
Total: 1 directory, 4 files, 0 symlinks
New: 4 files, 0 symlinks
77399 bytes transferred
lftp zhu@192.168.70.137:~> ls
-rw-r–r– 1 500 500 585 Sep 09 17:35 checkSYSConfig.ini
-rw-r–r– 1 500 500 14323 Sep 09 17:35 checklastLoginAndipTables.py
drwxr-xr-x 2 500 500 4096 Sep 09 21:33 iptables
-rw-r–r– 1 500 500 2764 Sep 09 17:35 zabbix_sender.py
-rw-r–r– 1 500 500 0 Sep 09 17:32 zhujiangtao
drwxr-xr-x 2 500 500 4096 Sep 09 21:30 zhuzhu