In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use lftp under linux. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
The function of lftp is more powerful, compared with the original use of ftp, a lot of convenience.
1. Log in:
Lftp ftp://yourname@site
Pwd:*
Or open ftp://yourname@site
2. Basic operation (transfer)
Introduction to use of lftp
Lftp is a powerful download tool that supports protocols for accessing files: ftp, ftps, http, https, hftp, fish. (where ftps and https need to include openssl libraries at compile time). Llftp's interface is very much like a shell: command completion, history, allowing multiple background tasks to execute and other functions, very easy to use. It also has bookmarks, queuing, mirroring, breakpoint continuation, multi-process download and other functions.
Command line syntax
To see the command line syntax of lftp, just type lftp-- help in shell
Lftp [OPTS]
'lftp' is the first command that lftp executes after the rc file is executed
-f exit after executing the command in the file
-c exit after executing the command
-- help exits after displaying help information
-- version exits after displaying lftp version
Other options are the same as the 'open' command
-e execute the command after selection
-u [,] authenticate with the specified username / password
-p connect to the specified port
Hostname, name of URL or bookmark
If you enter the site name on the command line, lftp will log in directly to the site, such as
$lftp ftp://.............
If you do not enter a 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 command
* download a single file and a group of files, and continue to use the-c parameter at the breakpoint.
Lftp.: / > get-c ls-lR.txt
Lftp.: / > mget. Txt
* Image (anti-image is uploaded) A directory, which can be mirrored by multiple threads in parallel (--parallel=N)
Lftp.: / > mirror incoming local_name
Lftp.: / > mirror-R local_name
Lftp.: / > mirror-parallel=3 incoming local_name
* Multithreaded 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, if you press Ctrl+z, the task you are executing will go to the background, or you can add a & symbol at the end of the command line to make the task execute in the background. You can view all background processes with the jobs command. You can queue up new tasks with the queue command. If you exit lftp and the task is executed in the background, the lftp will be transferred to background execution.
* other uses
Lftp supports pipe operations similar to bash, for example, you can save the size of all files in a specific directory (or the entire site) on the ftp server to the local file ls.txt with the following command
Lftp.: / > du incoming > ls.txt
Related documents
/ etc/lftp.conf
Global configuration file, the actual location depends on the system configuration file directory, either in / etc or / usr/local/etc
~ / .lftp / rc, ~ / .lftprc
The user profile will be executed after / etc/lftp.conf, so the settings in this will override the settings in / etc/lftp.conf.
Lftp does not display welcome messages and error messages from the ftp server by default, which is inconvenient in many cases, because you may want to know whether the server is not connected or the number of connections is full. If so, you can write a line in ~ / .lftprc
Debug 3
You can see the error message.
For more configuration options, please refer to the man manual or use the command set-an in the lftp interface.
~ / .lftp/log
When lftp is switched to background non-pending mode execution, the output will be redirected here
~ / .lftp/bookmarks
This is 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 characters are often garbled.
Don't panic, this is due to the inconsistency between the server and the local code. We just need to create a new file ~ / .lftprc or ~ / .lftp/rc in the home directory.
And add the following to it:
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"
Log in to the ftp server
Back to the point, let's 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
All of the above methods work well, but the passwords are all in clear text, so it doesn't seem to be safe. Never mind
Lftp user@site:port
The system will prompt for password, and the password will be echoed as *.
But it's troublesome to enter so much every time. It would be nice to have a site manager like leapftp. In fact, lftp has already figured it out for us: this is bookmark. We'll see later.
Common command
Run at the terminal
Man lftp
Or enter after logging in to ftp
Help
You can see the list of commands.
Let's take a look at the commands commonly used by lftp:
Ls
Displays a list of remote files (! ls displays a list of local files).
Cd
Switch the remote directory (lcd switch the local directory).
Get
Download the remote file.
Mget
Download remote files (you can use wildcards, that is, *).
Pget
Use multiple threads to download remote files, default to five.
Mirror
Download / upload (mirror-R) / synchronize the entire directory.
Put
Upload files.
Mput
Upload multiple files (wildcards are supported).
Mv
Move the remote file (renamed the remote file).
Rm
Delete the remote file.
Mrm
Delete multiple remote files (wildcards are supported).
Mkdir
Create a remote directory.
Rmdir
Delete the remote directory.
Pwd
Displays the current remote directory (lpwd displays the local directory).
Du
Calculate the size of the remote directory
!
Execute the command of the local shell (since lftp does not have lls, it can be replaced by! ls)
Lcd
Switch local directory
Lpwd
Show local directory
Alias
Define alias
Bookmark
Set bookmarks.
Exit
Exit ftp
Quick bookmark
Supplementary author: aBiNg
The bookmark command in ftp is to write the configuration to the ~ / .lftp / bookmarks file; we can modify this file directly to quickly log in to the ftp server.
3. Mirror synchronous image and backup server files
The main problem today is to solve the problem of how to back up server-side files. After understanding the use of the mirror instruction, I found it more suitable and easy to use.
Basic usage:
1) download server-side files:
# mirror-vn RCD LCD / / RCD is the remote path and LCD is the local path
2) upload files:
# mirror-R LCD RCD
A script for automatic synchronization is attached below:
#! bin/bash
Echo "script start at `date" + Y-%m-%d H:%M:%S "
HOST= "hostname"
USER= "yourname"
PASS= "password"
LCD= "LocalePath"
RCD= "RemotePath"
/ usr/sbin/lftp
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.