Summary of lftp usage in Linux system

  
                

Linux many operations, lftp can be used for ftp file download and upload, login ftp, etc., have a variety of ways to use, the following small series for lftp to give you a detailed introduction, interested friends may wish to understand.

1, the landing:

lftp ftp: //yourname @ site

pwd: *****

or open ftp: //yourname@site

2, basic operations (transfer)

lftp use introduction

lftp is a powerful download tool that supports access to file protocols: ftp , ftps, http, https, hftp, fish. (where ftps and https need to include the openssl library at compile time). The llftp interface is very much a shell: it has command completion, history, and allows multiple background tasks to be executed. It is very convenient to use. It also has bookmarks, queues, mirrors, breakpoints, multi-process downloads and more.

Command Line Syntax

To see the command line syntax of lftp, just type lftp in the shell --help

lftp [OPTS]

‘ Lftp’ is the first command executed by lftp after the rc file is executed.

-f Exit after executing the command in the file

-c Exit after executing the command

-- Help Exit help after displaying help information

--version Exit after displaying lftp version

Other options are the same as ‘open’ command

-e Execute command after selection

-u [,] Verify with the specified username/password

-p connect to the specified port

hostname, URL or bookmark name

If you enter the site name in the command line, lftp will log in directly to the site, such as

$lftp ftp://. . . . . . . . . . . . .

If you do not enter the site name on the command line, you must open it with the open command after entering the lftp interface.

[yhj@ccse-yhj yhj]$ lftp

lftp :~" open ftp://. . . . . . . . . . . . . . . . . . .

Common Commands

* Download a single file and a set of files, and use the -c parameter

lftp for a breakpoint. . . . . . . . . . . . . . . . :/" get -c ls-lR.txt

lftp . . . . . . . . . . . . . . . :/> mget *.txt

* Mirror (anti-image upload) a directory, you can use a plurality of threads to mirror a directory in parallel (--parallel=N)

lftp. . . . . . . . . . . . . . . . :/" mirror incoming local_name

lftp . . . . . . . . . . . . . . . . :/" mirror -R local_name

lftp . . . . . . . . . . . . . . . . :/" mirror --parallel=3 incoming local_name

* Multi-threaded download, similar to the function of network ants; the default is 5 threads

lftp. . . . . . . . . . . . . . . . :/" pget -n 4 ls-lR.txt

* Background task management

By default, pressing Ctrl+z will cause the task to be executed to be executed in the background, or Add the & symbol at the end of the command line to make the task execute in the background. Use the jobs command to view all background processes. Use the queue command to queue new tasks. If you exit lftp and there are tasks in the background, lftp will be converted to background execution.

* Other usages

lftp supports pipeline operations like bash. For example, use the following command to save the size of all files in a specific directory (or the entire site) on the ftp server. Local file ls.txt in

lftp. . . . . . . . . . . . . . . . :/》du incoming 》 ls.txt

Related files

/etc/lftp.conf

Global configuration file, the actual location depends on the system configuration file directory, possibly in /Etc, also in /usr/local/etc

~/.lftp/rc, ~/.lftprc

user configuration file, will be executed after /etc/lftp.conf, so This setting overrides the settings in /etc/lftp.conf.

lftp does not display the welcome message and error information of the ftp server by default. This is inconvenient in many cases, because you may want to know if the server is not connected or the connection is full. . If so, you can write a line in ~/.lftprc

debug 3

to see the error message.

For more configuration options, please check the man page or use the command set -a in the lftp interface.

~/.lftp/log

When lftp is converted to background non-suspend mode, the output will be redirected here

~/.lftp/bookmarks

This is the place where lftp stores bookmarks. You can view the bookmark command by lftp

~/.lftp/cwd_history

This file is used to store the working directory of the visited site

~/.lftprc

When using lftp to access some domestic ftp servers, the Chinese that you often see is garbled

^_^ don’t panic, this is because the server and local encoding are inconsistent. Caused. We just need to create a new file ~/.lftprc or ~/.lftp/rc

in the main directory and add the following content:

debug 3set ftp:charset GBKset file:charset UTF- 8#set ftp:passtive-mode no#alias utf8 “ set ftp:charset UTF-8”#alias gbk “ set ftp:charset GBK”

Login to ftp server

Closer to home, Let's first take a look at how to log in to the ftp server

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

lftp user:password@site:port

lftp site - p port -u user,password

lftp site:port -u user,password

The above methods work fine, but the passwords are plain text, so it seems not very safe. . It doesn't matter

lftp user@site:port

The system will prompt you to enter password, and the password will be displayed as ******

but you will enter so much each time. It’s so troublesome. If there is a site manager like leapftp, in fact, lftp has long thought of us: This is the bookmark. We will see later.
Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved