Use lftp to upload and download files in linux

Source: Internet
Author: User

Lftp is an ftp server in linux, which is much more complicated than ftp in windows. Next I will summarize the commands related to lftp file upload, file download, and file search.

Lftp name @ site is the most common method for lftp connection, so that you do not need to enter the password in plaintext.

1. lftp name @ site enter the password
2. lftp name: password @ site press ENTER
3. Enter the login username and password for the lftp site.
4. lftp press ENTER open site press ENTER login username and password

Lftp File Upload Command

Upload a single file

The Code is as follows: Copy code

Lftp webmaster@phpyuandi.com @ 115.47.192.146:/> put test.txt ./
Put:/root/Desktop/new/test: Is a directory

Upload multiple files

The Code is as follows: Copy code

Lftp webmaster@phpyuandi.com @ FIG:/> mput *. txt ./

Full-site upload

The Code is as follows: Copy code

Lftp webmaster@phpyuandi.com @ MAID:/> mirror-R test./test
Total: 1 directory, 2 files, 0 symlinks
New: 2 files, 0 symlinks

Lftp File Download command

Get to download a single object

The Code is as follows: Copy code

Lftp webmaster@phpyuandi.com @ 115.47.192.146:/> get html. php
8473 bytes transferred

Select Download with a certain extension under a directory

The Code is as follows: Copy code
Lftp webmaster@phpyuandi.com @ 115.47.192.146:/your directory> mget *. php
[0] mget *. php &
'Image _ class. php' at 0 (0%) [Making data connection...]
Mget

Resumable upload

The Code is as follows: Copy code
Lftp webmaster@phpyuandi.com @ 115.47.192.146:/> mget-c./your directory /*.*
Mget:/root/Desktop/new: Is a directory
[0] mget-c./your directory /*.*&
'Your directory/business_edit.php 'at 1126 (100%) [Making data connection...]

Download the entire site

The Code is as follows: Copy code
Lftp webmaster@phpyuandi.com @ 115.47.192.146:/> mirror/
[0] mirror /&

Download the entire directory

The Code is as follows: Copy code

Lftp webmaster@phpyuandi.com @ 115.47.192.146:/> mirror your directory/
[1] mirror your directory /&

Resumable upload of the entire directory

The Code is as follows: Copy code

Lftp webmaster@phpyuandi.com @ 115.47.192.146:/> mget-c your directory /*
[0] mget-c your directory /*&
'Your directory/info_class.php' at 0 (0%) [Waiting for response...]

Lftp file search command

Ls *. php: Find the php file in the current directory

The Code is as follows: Copy code
Lftp webmaster@phpyuandi.com @ MAID:/> ls *. php
Total 16
-Rw ------- 1 www 2037 Nov 24 cai. php
-Rw-r -- 1 www 8473 Oct 25 html. php

Ls./admin/find the files in the admin directory

The Code is as follows: Copy code
Lftp webmaster@phpyuandi.com @ MAID:/> ls./admin/
Total 444
-Rw-r -- 1 www 611 Aug 2 application. php
-Rw-r -- 1 www 391 Aug 2 application_info.php
-Rw-r -- 1 www 858 Aug 6 banner. php
-Rw-r -- 1 www 650 Aug 2 banner_add.php
-Rw-r -- 1 www 1026 Aug 2 banner_edit.php
-Rw-r -- 1 www 1434 Aug 6 business. php
-Rw-r -- 1 www 788 Aug 3 business_add.php
-Rw-r -- 1 www 277 Aug 3 business_bigclass_add.php
-Rw-r -- 1 www 473 Aug 3 business_bigclass_edit.php
-Rw-r -- 1 www 484 Aug 3 business_class.php
-Rw-r -- 1 www 234 Aug 3 business_class_del.php
-Rw-r -- 1 www 1126 Aug 3 business_edit.php
-Rw-r -- 1 www 759 Aug 3 business_smallclass_add.php
-Rw-r -- 1 www 871 Aug 3 business_smallclass_edit.php
-Rw-r -- 1 www 44402 Aug 10 2011 cai. php
-Rw-r -- 1 www 930 Nov 11 check_login.php
Drwxr-xr-x 2 www 4096 Aug 12 css
Ls./admin/year *. php: Find the php file containing year in the admin directory.
Lftp webmaster@phpyuandi.com @ 115.47.192.146:/> ls./admin/year *. php
Total 12
-Rw-r -- 1 www 651 Aug 6 year. php
-Rw-r -- 1 www 401 Jul 28 year_add.php
-Rw-r -- 1 www 531 Aug 4 2011 year_edit.php


Common commands

Run on the terminal
Man lftp
Or enter
Help
The command list is displayed.
Let's take a look at common commands of lftp:
Ls
Display the remote file list (! Ls to display the local file list ).
Cd
Switch the remote directory (LCD switches to the local directory ).
Get
Download remote files.
Mget
Download a remote file (wildcard * can be used *).
Pget
Use multiple threads to download remote files. The default value is five.
Mirror
Download/upload (mirror-R)/synchronize the entire directory.
Put
Upload a file.
Mput
Upload multiple files (Wildcards are supported ).
Mv
Move the remote file (rename the remote file ).
Rm
Delete a 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
!
Run the local shell command (because lftp does not have lls, it is available! Ls to replace)
LCD
Switch local directory
Lpwd
Show local directory
Alias
Define aliases
Bookmark
Set bookmarks.
Exit
Exit ftp
Quick bookmarks

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.