Lftp is a tool that supports downloading, uploading, and screen usage. It is equivalent to an ftp client that supports file access.Protocols include ftp, ftps, http, https, hftp, and fish.
1. login method:
Lftp User name: password @ IP Address
[root@zhu2 ~]# lftp zhu:123456@192.168.70.137lftp zhu@192.168.70.137:~> ls -ldrwxr-xr-x 9 500 500 4096 Sep 09 16:02 LVS-rw-r--r-- 1 500 500 0 Sep 09 15:52 txt1
Lftp username @ IP Address
Lftp 192.168.70.133: ~> Bye [root @ zhu2 ~] # Lftp zhu@192.168.70.137 password: lftp zhu@192.168.70.137: ~> Ls-ldrwxr-xr-x 9 500 500 4096 Sep 09 LVS-rw-r -- 1 500 500 0 Sep 09 txt1
Lftp IP address-p port number-u user, password
[root@zhu2 ~]# lftp 192.168.70.137 -u zhu,123456lftp zhu@192.168.70.137:~>
Lftp IP Address: Port-u user, password
[root@zhu2 ~]# lftp 192.168.70.137:21 -u zhu,123456lftp zhu@192.168.70.137:~>
2. Common commands
Help: view the file list
lftp zhu@192.168.70.137:~> help!<shell-command> (commands)alias [<name> [<value>]] anonbookmark [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: view files or directories on the remote host
! Ls: view the file list in the local directory
lftp zhu@192.168.70.137:~> lsdrwxr-xr-x 9 500 500 4096 Sep 09 16:02 LVS-rw-r--r-- 1 500 500 0 Sep 09 15:52 txt1lftp zhu@192.168.70.137:~> !lsiptables lnmp LVS
Pwd: displays the directory on the remote host
Lpwd: displays the local directory
lftp zhu@192.168.70.137:~> pwdftp://zhu:123456@192.168.70.137:21/%2Fhome/zhulftp zhu@192.168.70.137:~> lpwd/root
Cd: Switch the directory of the remote host
LCD: Switch the local directory
Lftp zhu@192.168.70.137: ~> Pwdftp: // zhu: 123456@192.168.70.137: 21/% 2 Fhome/zhulftp zhu@192.168.70.137: ~> Lpwd/rootlftp zhu@192.168.70.137: ~> Zhu@192.168.70.137 cd lvslftp :~ /Lvs> pwdftp: // zhu: 123456@192.168.70.137: 21/% 2 Fhome/zhu/lvslftp zhu@192.168.70.137 :~ /Lvs> LCD/root/iptables/LCD success, local directory =/root/iptableslftp zhu@192.168.70.137 :~ /Lvs> lpwd/root/iptables
Get File Name: Download a single file to the current local directory
lftp zhu@192.168.70.137:~> get txt1lftp zhu@192.168.70.137:~> !lsiptables lnmp LVS txt1
Mget supports wildcard characters to download multiple files at the same time)
lftp zhu@192.168.70.137:~/lvs> mget auto*3429843 bytes transferredTotal 2 files transferredlftp zhu@192.168.70.137:~/lvs> !lsautoconf-2.68.tar.gz automake-1.11.2.tar.gz iptables lnmp LVS txt1
Put file name: Upload a local file to the current directory of the remote host.
lftp zhu@192.168.70.137:~> put zabbix_sender.py2764 bytes transferredlftp zhu@192.168.70.137:~> ls -ldrwxr-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 zhujiangtaodrwxr-xr-x 2 0 0 4096 Sep 09 17:32 zhuzhu
Mput: supports wildcard characters for simultaneous uploading of multiple files
lftp zhu@192.168.70.137:~> mput check*14908 bytes transferredTotal 2 files transferredlftp 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.pydrwxr-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 zhujiangtaodrwxr-xr-x 2 0 0 4096 Sep 09 17:32 zhuzhu
The get and put commands are for files,
To target a directory, you can use another command. Mirror
3. mirror command usage
Mirror directory name: Download the entire directory, including the subdirectories contained in the directory)
lftp zhu@192.168.70.137:~> mirror lvs/Total: 130 directories, 3401 files, 7 symlinksNew: 3401 files, 7 symlinks69273581 bytes transferred in 25 seconds (2.65M/s)lftp zhu@192.168.70.137:~> !ls lvs7e3a82377fa8.tar.bz2 ClusterLabs-resource-agents-b735277 libnet-1.1.6autoconf-2.68 glue-1.0.9.tar.bz2 libnet-1.1.6.tar.gzautoconf-2.68.tar.gz Heartbeat-3-0-7e3a82377fa8 Reusable-Cluster-Components-glue--glue-1.0.9automake-1.11.2 ipvsadm-1.24 v3.9.2automake-1.11.2.tar.gz ipvsadm-1.24.tar.gz
Mirror remote directory local directory: Download the remote directory to the local directory and rename it
Lftp zhu@192.168.70.137: ~> Mirror zhuzhu/taotaoTotal: 1 directory, 1 file, 0 symlinksNew: 1 file, 0 symlinkslftp zhu@192.168.70.137: ~> Bye [root @ zhu2 ~] # [Root @ zhu2 ~] # Ll total 16drwxr-xr-x 2 root 4096 09-06 20:32 iptablesdrwxr-xr-x 14 root 4096 09-02 lnmpdrwxr-xr-x 9 root 4096 09-03 LVSdrwxr- xr-x 2 root 4096 09-09 05:38 taotao
Mirror.: Download all files and directories in the current directory of the remote host.
[root@zhu2 ~]# lftp 192.168.70.137 -u zhu,123456lftp 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 zhujiangtaodrwxr-xr-x 2 500 500 4096 Sep 09 21:30 zhuzhulftp zhu@192.168.70.137:~> mirror .Total: 2 directories, 5 files, 0 symlinksNew: 5 files, 0 symlinks17672 bytes transferredTo be removed: 18 directories, 15 files, 0 symlinkslftp zhu@192.168.70.137:~> !lschecklastLoginAndipTables.py iptables LVS zhujiangtaocheckSYSConfig.ini lnmp zabbix_sender.py zhuzhu
Mirror-R local directory: Upload the entire directory
[root@zhu2 ~]# lftp 192.168.70.137 -u zhu,123456lftp zhu@192.168.70.137:~> mirror -R iptables/Total: 1 directory, 4 files, 0 symlinksNew: 4 files, 0 symlinks77399 bytes transferredlftp 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.pydrwxr-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 zhujiangtaodrwxr-xr-x 2 500 500 4096 Sep 09 21:30 zhuzhu
This article is from the "Lang taosha" blog, please be sure to keep this source http://caisangzi.blog.51cto.com/6387416/1295274