LFTP – FTP Download Client

LFTP is a sophisticated ftp/http client, and a file transfer program supporting a number of network protocols. Like BASH, it has job control and uses the readline library for input. It has bookmarks, a built-in mirror command, and can transfer several files in parallel. It was designed with reliability in mind.

InstallingLinux Install lftp with your package manager, something like :

sudo apt-get install lftp

Connecting to “Server”

Open your terminal  and Start lftp and connect to “Server”.
Type lftp sftp://user@server.com.
Enter your password at the prompt. lftp keeps your password hidden, so it’s easiest to paste with the right-click menu.
Type ls in the terminal to show a listing of your home directory.
(optional) If you want your password to be saved when you create a bookmark:
Use command : set bmk:save-passwords true .
Use command : bookmark add “Server” to bookmark  your slot named Server.
Use command : bookmark list to make sure it saved properly.
Use command : lftp Server in the terminal will now open a connection to your server instead of having to type out the address.

Local and Remote Navigation

Use command : cd to go down one level into a directory.
Use command : cd .. to go up one level.
Type ls to see that you’re back in your home directory.
Use command :cd to navigate directly to a directory more than one level away. cd ~/files/Video .
Navigate to directories on your computer
Use command :lcd (read: local cd) command. Type lcd /path/to/directory.
To list what’s in the current local directory, add an exclamation point to the ls command like !ls.

Transfers

There are two main commands used for downloading:
pget for files : e.g. pget DiskImage1.iso
mirror for directories : e.g. mirror Video/
There are two main commands used for uploading:
put for files : e.g. put DiskImage1.iso
mirror -R for directories  : e.g. mirror -R Video/
To cancel a transfer, use  Ctrl+c
To resume partially downloaded files/directories, you will use the -c switch:
mirror -c Directory     pget -c Video1.mp4      put -c Video1.mp4

Segmented Downloading (Note: This guide uses 5 segments as an example.)

Use command : pget with 5 segments : -n 5 on file : Video2.mp4
e.g. pget -n 5 Video2.mp4
Use command : mirror with 5 segments : –use-pget-n=5 on Directory : Directory
e.g. mirror –use-pget-n=5 Directory
Use command : jobs -v to see the speeds of the individual segments as well as the total speed.

Parallel Downloading (Note: This guide uses 5 simultaneous downloads as the example.)

Use command :  mirror  that downloads multiple files in parallel.
e.g. <mirror -P5 Directory or mirror –parallel=5
A mirror command that downloads multiple files at once and uses segmentation : e.g.mirror -P 5 –use-pget-n=2 Directory or mirror –parallel=5 –use-pget-n=2
(where 5 is the max number of files to download simultaneously and 2 is the number of segments to use per file)

Queues and Jobs

The queue command will allow you to transfer files/directories while still being able to browse.
e.g. queue pget Video1.mp4
e.g. queue mirror Directory
This adds them to your transfer queue and automatically starts the transfer if ready.

Use command : queue alone to display your transfer queue.
Use command : jobs to displays current transfers and transfer queue with more detail.

Use command : queue stop will stop queue, this can be used before adding anything to your queue to prevent immediate transfer.
Use command : queue start will start your queued transfers.

To delete a transfer from your queue, add the -d switch e.g.queue -d #, where # is the queue number listed by jobs or queue
Use command : kill To stop and delete a running transfer.
Use command : kill # If queued multiple transfers, where # is the number listed by jobs.

Use command : kill all will stop and delete all transfers.

Configuration and Aliases

Aliases allow you to make shortcuts to commands.
In Linux, find the configure file, it is located an /etc/lftp.conf
Here are my personal aliases as a guide for you. Remember to edit the file as sudo.
Copy and paste this to the end of the file :
(Replace “USER” with your username.)


# Local locations
alias d "lcd /home/"USER"/Downloads"
alias x "lcd /media/"USER"/Current_Seeds"

# Common commands
alias q "queue"
alias j "jobs"
alias jv " jobs -v"
# Segmented download of File
alias p40 "pget -n 40"
alias p30 "pget -n 30"
alias p20 "pget -n 20"
alias p10 "pget -n 10"
alias p5 "pget -n 5"
# Segmented download of folder
alias s40 "mirror -c --use-pget-n=40"
alias s30 "mirror -c --use-pget-n=30"
alias s20 "mirror -c --use-pget-n=20"
alias s10 "mirror -c --use-pget-n=10"
alias s5 "mirror -c --use-pget-n=5"
# Parallel download of folder
alias m40 "mirror -c --parallel=40"
alias m30 "mirror -c --parallel=30"
alias m20 "mirror -c --parallel=20"
alias m10 "mirror -c --parallel=10"
alias m5 "mirror -c --parallel=5"

Tips and Tricks

The Tab key to auto-completes file and directory names. It also auto-completes commands.
Files and directories with spaces or special characters need special handling.
The easiest method is to put quotes around the file/directory names.
You can cycle through previously used commands with the Up and Down arrow keys.
To quit lftp, type exit. Then type exit again to close the terminal.

Refrence material :
https://whatbox.ca/wiki/lftp
https://lftp.yar.ru/lftp-man.html
https://en.wikipedia.org/wiki/Lftp

Leave a Reply

Your email address will not be published. Required fields are marked *