Home > Article > Operation and Maintenance > Log in to ftp under linux, detailed explanation of lftp command
Use lftp
1. Log in to ftp
Code:
lftp Username: Password@ftp address: Transfer port (default 21)
Usage
(1)lftp username:password@127.0.0.1:21 Enter
(2)lftp username@127.0.0.1 Enter ##Default port 21 Enter password after entering
(3)lftp 127.0.0.1 Enter ##Enter and log in
(4)lftp Enter--> open 127.0.0.1 --> login Login
I feel a lot like Kong Yiji. There are several ways to write "fennel" in fennel beans! ~So dizzy~
2. lftp Chinese garbled code problem
For a novice like me, after logging in, all I see is Chinese garbled code (because generally the local encoding is utf-8) ), why not, use the set command to solve it
set ftp:charset gbk (or gb2312 or utf-8) ##Set the encoding format of the ftp end
set file:charset utf-8 (...Same as above) ##Set the local encoding format
Attachment: Tips for the set command (1) Enter set to view the set commands (2) set -a to view all the commands that can be set
3. Find ftp side files
ls *.txt ##Find all txt files in the current directory
ls ./123/ ##List all files in the 123 directory
find . -name "*.txt" ##Recursively search for all txt files on the site
find ./xx -name "*.txt" ##Find all txt files in the xx directory File
Attachment 1: The second time ls reads is the local cache, you can use rels instead of ls or catch off / catch on to switch catch, catch flush clears the local catch
Attachment 2: You can use !ls to browse local directories, such as !ls /usr/local/bin/
4. Download files
Before downloading files, you must first set up a local directory to store downloads. File
lcd /home/123/web ##Set the local storage directory to /home/usr by default
get 123.txt ##Download the 123.txt file to /home/123/ In web
get -c 123.txt ##Resumable download
mget *.txt ##Batch download all txt files
mget -c *.txt ##Resume breakpoint transmission
mget -c ./123/aaa/*.txt ##Resume breakpoint transmission, batch download all txt files in the aaa directory on the ftp end
pget - c -n 10 file.dat
##Download file.dat
##with up to 10 threads allowing resumed downloading
##Can be set by set pget:default-n 5 value and use the default value.
mirror aaa/
##Download the entire aaa directory, and the subdirectories will be automatically copied to the local directory and automatically created
5. Upload files
put 123.txt ##Same as download
mput *.txt ##Same as download
mirror -R aaa/ ##Same as download
6. Set passive/non Passive mode
set ftp:passive-mode 1 ## 1 passive 0 non-active
Multi-tasking
ctrl+z ##Transfer the current task to the background for processing
wait ##Move background processing tasks to the foreground to view
jobs ##View the list of tasks performed in the background
kill all or job_no ##Delete all tasks or the specified Task
##Add task to task list
queue get 123.txt
queue put 234.txt
queue mirror aaa/
queue ##View task list
jobs ##View background task list
queue start ##Start task list
queue stop ##Stop task list
Other commands
alias []
Define alias
alias less more
alias reconnect "close; cd ."
Enter alias directly to see which aliases are currently defined. If you only enter alias name, the alias name will be cancelled.
bookmark SUBCMD
Set bookmarks. You can set the current site and directory as bookmarks. You can enter directly next time without having to cd back and forth.
bookmark add name is used to add a bookmark named name
bookmark del name Delete the bookmark named name
bookmark list Displays the currently set bookmarks (in addition, directly type the results of bookmark and bookmark list) Same)
bookmark edit Call the editor to modify bookmarks (~/.lftp/bookmarks)
cd Switch remote directory
cache SUBCMD
Manage lftp cache
rels []
Display remote file list from cache
rels will not be read from cache
recls opts [path /]pattern
Displays the remote file list from the cache. It should be regarded as an enhanced version of ls. There are many parameters available. It should be used to generate various file lists for use by other programs.
recls will not be read from the cache
du options
Calculate the capacity occupied by the entire remote directory
get OPTS -o
Grab remote files
get rfile -o lfile
Grab rfile and rename it locally to lfile
-c for resume transfer
-E After the file grabbing is completed, cut the remote files
-a to ascii mode, the default is binary mode
-O Set the base directory to the local directory where the files are placed
mget OPTS
Download remote files (wildcard expansion is available, that is, *)
pget OPTS -o
Use multiple links to download files, default for five.
-n 3 For three links
jobs -v
Display which programs are currently running in the background
-v Display detailed information (- v You can add a few more to display more detailed information)
lcd
Switch the local directory
mirror OPTS remote [local]
###Download the entire directory (The get upstairs can only be used to grab files)###-c Resume
-e Be careful with this. Compare the remote and local files. If the remote files are not available, delete the local files, that is, combine the local and remote data. Synchronize.
-R Upload the entire directory
-n Download only newer files
-r No need to pass back to the directory
--parallel=n Download n files at the same time (default is to download only one at a time)
module name args
Load module
put OPTS -o
Upload file
mput OPTS
Upload files (wildcard expansion can be used, that is, *)
mv
Rename the remote file1 to file2
mrm
Use wildcard expansion to delete remote files
open OPTS
Open a site
open -u, -p site
queue OPTS []
Put cmd in the queue and wait for execution
-d index Delete the job numbered index
-m index new_index Will The job numbered index is moved to number new_index, which is only used for queue jumping.
-n index Add a new job before the number index
wait []
Move the program executing in the background to the foreground (fg can also be used)
kill all|
Delete all jobs or job_no
repeat delay command
Repeat command every delay seconds, the default is every second
rm -r -f
Remove remote files
mkdir -p
Create remote directory
rmdir -f
Remove the remote directory
set OPT []
Set variables
Type set directly to see which variables are currently defined
source
Read file and execute the command in file (it should be the same as the source command in bash)
debug [|off] -o
Set Set the debug level to level
-o and direct the output to file
exit [|bg]
End lftp
If there are still jobs at this time, Then lftp will be executed in the background and continue the unfinished work
history -w file-r file-c|-l cnt
The function is the same as the history in bash
renlist []
Only display the remote file name
pwd -p
Display the current remote directory
-p even with the login password Also displays
scache []
Only scache shows all current sessions, plus session_no can switch to other sessions,
For opening multiple sites at the same time or Switch between different directories on the same site.
The above is the detailed content of Log in to ftp under linux, detailed explanation of lftp command. For more information, please follow other related articles on the PHP Chinese website!