TrumanWong

lftp

Excellent file client program

Supplementary instructions

lftp command is an excellent file client program that supports multiple file transfer protocols such as ftp, SETP, HTTP and FTPs. lftp supports tab auto-completion. If you don’t remember the command, double-click the tab key to see the possible options.

grammar

lftp(options)(parameters)

Options

-f: Specify the script file to be executed by the lftp command;
-c: Exit after executing the specified command;
--help: display help information;
--version: Display the version number of the instruction.

Parameters

Site: The IP address or domain name of the site you want to visit.

Example

Login ftp

lftp username: password@ftp address: transfer port (default 21)

You can also log in without a user name first, and then use the login command in the interface to log in with the specified account. The password will not be displayed.

View files and change directories

ls
cd corresponds to the ftp directory

download

Of course get is possible, but also:

mget -c *.pdf #Download all PDF files in a way that allows resumed downloading.
mirror aaa/ #Download the entire aaa directory, and the subdirectories will also be automatically copied.
pget -c -n 10 file.dat #Download file.dat with up to 10 threads to allow resumed downloading. You can use the default value by setting the value of pget:default-n.

Upload

Similarly, put and mput are operations on files, similar to downloading.

mirror -R local directory name

Reversely upload the local directory to the ftp site in an iterative manner (including subdirectories).

Mode Settings

set ftp:charset gbk

The remote ftp site uses gbk encoding, and the corresponding encoding should be set to utf8. Just replace gbk with utf8.

set file:charset utf8

The local charset is set to utf8. If you are gbk, change it accordingly.

set ftp:passive-mode 1

Use passive mode to log in. Some sites require passive mode or active mode before you can log in. This switch is used to set this. 0 means no passive mode is used.

Bookmark

In fact, the command line can also have bookmarks. At the lftp terminal prompt:

bookmark add ustc

You can store the ftp site currently being browsed using ustc as a tag. In the future, in the shell terminal, directly lftp ustc will automatically fill in the user name and password and enter the corresponding directory.

bookmarkedit

The editor will be called to manually modify the bookmark. Of course, you can also see that this bookmark is actually a simple text file. Password and username can be seen.

Configuration File

vim /etc/lftp.conf

Typically, I would add these lines:

set ftp:charset gbk
set file:charset utf8
set pget:default-n 5

In this way, you don't have to type commands every time you enter. You can view other sets by tabbing and using help.