Linux

How to download file using lftp

lftp is a command-line FTP/HTTP client for Unix-like systems (Linux, BSD, macOS, etc.).
It’s like the traditional ftp command, but much more powerful and scriptable.

1. Install lftp (if not installed)

On most Linux distributions:

sudo apt install lftp     # Debian/Ubuntu
sudo yum install lftp     # CentOS/RHEL
sudo dnf install lftp     # Fedora

2. Connect to the FTP server

lftp -u username,password ftp.example.com
  • Replace username and password with your FTP login.

  • If the server allows anonymous FTP, you can connect with:

lftp ftp.example.com

3. Navigate and download files

Once connected, you’ll get an lftp shell similar to this:

lftp ftp.example.com:~>

Change directory on server:

cd /path/on/server

List files: 

ls

Download a single file: 

get filename.txt

Download and resume (if interrupted):

pget -c filename.txt

Download multiple files:

mget *.zip

4. Download directories

If you want a full folder (recursively):

mirror /remote/path /local/path

Examples:

  • Mirror everything into current local directory:

mirror 
  • Mirror with resume and verbose mode: 
mirror -c -v /remote/path /local/path 

Mirror only newer files: 

mirror -n /remote/path /local/path

5. Run in one command (non-interactive)

If you don’t want to open an interactive session:

lftp -u username,password ftp.example.com -e "cd /remote/path; get file.zip; bye"

Or mirror a folder directly:

lftp -u username,password ftp.example.com -e "mirror -c /remote/path /local/path; bye"

Thanks for vist my website