[Arrangement] Linux FTP client lftp usage

Source: Internet
Author: User
Tags openssl library remote ftp server ftp client linux ftp client

1. In one breath
$ Lftp (ftp: //) User: password @ site: Port
It is usually used for the off-the-shelf links provided on web pages or BBs. The disadvantage is that the password is displayed as a plain text. We recommend that you input it in a dark environment without any one.
$ Lftp (ftp: //) user @ site: Port
Then the system will prompt you to enter the password, which is ***

2. Regular Expression

$ Lftp site-P port-u user, password
This is the standard method provided in the lftp instruction document. This method is labor-intensive. Please do your best according to your health condition. If the physical fitness is normal, you can
$ Lftp site: Port-u user, password
It seems a little easier. I usually use this method.

3. Hide a length in the five short periods

This is a method for Recursive nesting #@! × &
$ Lftp
Lftp: ~> Lftp User: password @ site: Port
That is to say, the operations on the lftp console are exactly the same as those on the system terminal. You can still use the first two tricks with no scruples, or use o or open instead of lftp, you can also enter the format of the user name and password of the Website Based on your preference.

4. Ultimate Success

Every time I log on, I have been hitting a user: password @ site: port for a long time. Even if Li tie is here, I cannot help myself. Therefore, we still need to let lftp write down frequently-used sites, just like the platform manager in flashfxp, which is called bookmark in lftp. Let's talk about it later.

The first thing to do is to check what is good on this server. The operation is the same as in the terminal. ls is used to list the server directories. One thing to note is that after the first ls operation, the directory table is saved to the local cache, so that the latest list under this directory cannot be obtained after the LS operation. In this case, you can use rels to download the directory table again. Here, the cache is the default setting of lftp. The purpose is to get a list faster, but sometimes it does not match your usage habits. You can use cache on and cache off to switch the cache, or use cache flush to clear the cache. There is nothing to say about changing the directory. lftp also supports the tab matching function, greatly reducing the labor intensity.

Lftp supports six modes: FTP, ftps, HTTP, https, hftp, fish and file (of course, https and ftps support must be compiled together with OpenSSL library ).

Lftp has built-in shell-like command format, allowing multiple commands (&) to be executed at the same time in the background (&). All background tasks are executed in the same program (process). commands that can be run in the foreground can be executed in the background (CTRL-Z ), or get back the foreground execution (wait or fg) from the background, or even determine whether to execute the current command (& |) through the return value of the previous command ).

At the end of lftp, if a program is still running, lftp will switch itself to the No hup mode and put it in the background for execution. Therefore, you do not have to worry about the failure to log out during lftp execution.

!
Execute commands in the local shell, such! Ls/usr/local/bin/Since lftp does not have LLS (commands for displaying the local file list), it is available! Ls.

Alias []
Define aliases
Alias less more
Alias reconnect "close; CD ."
Enter alias directly to see the aliases currently defined. If you only enter alias name, the alias name is canceled.

Bookmark subcmd
Set the book category. You can set the current platform and directory as a book category. Next time you can directly come in without CD.

Bookmark Add name is used to add a book named name
Bookmark del name: delete a book named name
The bookmark list shows that there are currently set the book lists (In addition, the results of directly typing bookmark and bookmark list are the same)
Bookmark edit call Editor (~ /. Lftp/bookmarks)

CD switch remote directory

Cache subcmd
Manage lftp Cache

Rels []
Display the remote file list from the cache
Rels will not read from the cache

Recls opts [path/] Pattern
Display the remote file list from the cache. It should be an enhanced version of LS. There are many parameters available, which should be used to generate various> file lists for use by other programs.
Recls will not read from the cache

Du options
Calculate the quota capacity of the entire remote directory

Get opts-o
Capture remote files

Get rfile-O lfile
Capture rfile and rename it lfile
-C: Resume
-E. After the file is captured, the remote file is cut down.
-A is an ASCII mode and the default value is binary mode.
-O sets the base directory as the directory for storing files on the local end.

Mget opts
Download the remote file (wildcard expansion is available *)

Pget opts-o
You can use multiple links to download five files by default.
-N 3 indicates three links.

Jobs-V
Show which programs are currently executed in the background
-V displays detailed information (-V can add more details to display more detailed information)

LCD
Switch the local directory

Mirror opts remote [local]
Download the entire directory (get upstairs can only be used to capture files)
-C resume
-E be careful when comparing remote and local files. If the remote files do not exist, delete the local files, that is, synchronize the local and remote data.
-R: Upload the entire directory
-N: only download newer files
-R does not need to be handed over to the directory.
-- Parallel = N simultaneously downloads n files (only one file is downloaded at a time by default)

Module name ARGs
Load Module

Put opts-o
Upload files

Mput opts
Upload a file (wildcard expansion is also available *)

MV
Rename the remote file1 to file2

Mrm
Use wildcard expansion to delete remote files

Open opts
Start a platform
Open-u,-P site

Queue opts []
Put CMD in the queue for execution
-D index: Delete the job numbered Index
-M index new_index: Move the job numbered index to new_index, which is dedicated to plug-in.
-N index: adds a job before the index number.

Wait []
Move the program in background execution to the foreground (FG is also available)

Kill all |
Delete all jobs or job_no

Repeat DELAY command
Execute Command again every delay seconds. The default value is every second.

Rm-r-F
Remove remote files

Mkdir-P
Create remote directory

Rmdir-F
Remove remote directory

Set OPT []
Set variable
Directly type set. You can see the variables defined currently.

Source
Read the file and execute the command in file (it should be the same as the source command in bash)

Debug [| Off]-o
Set debug level to level
-O directs the output to file

Exit [| BG]
End lftp
If there are still jobs, lftp will be placed to the background for execution and the unfinished work will continue.

History-W file-r file-c |-l CNT
Like history in bash

Renlist []
Show only remote file names

PWD-P
Displays the current remote directory
-P: the logon password is displayed.

Scache []
Only use scache to display all current sessions. With session_no, you can switch to other sessions,
Switch between directories on multiple platforms or on the same platform at the same time.

The younger brother has met some platforms, and an IP address is only allowed to log on once. If he wants to keep a large number of files under different directories at the same time, he can only capture one file at a time, after the command is finished, you can switch to another directory to capture the second one. Then, the queue of lftp will be used. Generally, if get and mget are used, the file will be downloaded directly, and the file cannot be switched to another directory. Therefore, stop the queue first, and then press Enter, next job, we can see that the current queue is stopped. Then add the stuff to the queue one by one, and wait until the stuff to be captured enters
After the queue, start the queue and send it all at once. This saves you the trouble of checking whether the file is fully captured at any time.

Lftp localhost:/pub/ISO> queue

Lftp localhost:/pub/ISO> jobs
0 Queue (ftp: // localhost)
Queue is stopped.

Lftp localhost:/pub/ISO> queue get rettcd. ISO

Lftp localhost:/pub/ISO> jobs
0 Queue (ftp: // localhost)
Queue is stopped.
Commands queued:
1. Get rettcd. ISO

Lftp localhost:/pub/ISO> queue mirror Linux/

Lftp localhost:/pub/ISO> jobs
0 Queue (ftp: // localhost)
Queue is stopped.
Commands queued:
1. Get rettcd. ISO
2. Mirror Linux/

Lftp localhost:/pub/ISO> queue start

Lftp localhost:/pub/ISO> jobs
0 Queue (ftp: // localhost)
Now executing: 1 get rettcd. ISO
Commands queued:
1. Mirror Linux/
1 get rettcd. ISO
'Rettcd. iso' at 4772864 (9%) 3.00 m/s ETA: 14 s refreshing data
Related Files

/Etc/lftp. conf
The actual location of the global configuration file depends on the directory of the system configuration file, which may be in/etc or/usr/local/ET.
C

~ /. Lftp/RC ,~ /. Lftprc
The user configuration file will be executed after/etc/lftp. conf, so the above settings will overwrite the settings in/etc/lftp. conf.
By default, lftp does not display the FTP server's welcome information and error information, which is inconvenient in many cases, because you may want to know whether the server is unable to connect to the server because it is not powered on or the number of connections is full. If so, you can ~ /. Write a row in lftprc

Debug 3

The error message is displayed.
For more configuration options, see the man manual or use the set-a command on the lftp interface.

~ /. Lftp/log
When lftp is switched to the background non-suspended mode for execution, the output will be redirected here

~ /. Lftp/bookmarks
This is where lftp stores bookmarks. You can use lftp to view the bookmark command.

~ /. Lftp/cwd_history
This file is used to store the working directory of the accessed site

When a problem occurs in displaying the Chinese character set, the charset of the remote FTP server is gb2312. If I directly use ls, all Chinese characters are garbled and there is no way to use it. Just give a parameter like this:

Lftp ryun@www.example.com:/> set ftp: charset gb2312

Then, let's take a look at ls to see if it's more friendly. ^____ ^

There is also a way to set the configuration file for friends who frequently use the Chinese Character Set ftp:

Touch ~ /. Lftp/RC
Echo 'debug 4'> ~ /. Lftp/RC
Echo 'set ftp: charset gbk'> ~ /. Lftp/RC

Now, lftp supports displaying Chinese characters directly.

Unable to connect in passive mode, you can column the directory after converting to active mode: After logging on to lftp, execute:
Set ftp: passive-mode No

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.