lftp usage on Linux

This post introduces lftp usage on Linux.

(Thanks Scott for sharing this nice tool.)

lftp is a command-line program client for several file transfer protocols. lftp is designed for Unix and Unix-like operating systems.

1: Installation on Ubuntu:

$ sudo apt-get update
$ sudo apt-get install lftp

2: Some commonly used commands with lftp:

ls  — list direcotries and files on remote ftp server

cd — change directory on remote ftp server

lpwd — list local machine current directory

lcd — change local directory

mput *.csv  — mput for multiple files, put for a single specific file.

This will take from the current local directory  and put into the current remote directory on  remote ftp server.

copy directory and its contents to and from ftp server (from and to local machine):

mirror -c -R  path/to/localdirectory/   

This will copy local directory to (the current directory) on the  remove ftp server  , c means continue)

       mirror -c  path/to/remote/directory

This will copy the remote directory  to (the current local directory  , c means continue)

(for more commands, check the lftp man page provided in the references below.)

3: Using Box under Linux (using lftp)

The lftp command is a powerful file transfer client that can be used with Box.

Box supports the secure FTPS protocol and you can use this with lftp for secure file transfer and mirroring.

The lftp command is smart enough to auto-negotiate to use FTPS but this example forces the issue to make absolutely sure unencrypted FTP is never attempted.

Here is an example of how to connect using FTPS.

$ lftp
lftp :~> set ftps:initial-prot ""
lftp :~> set ftp:ssl-force true
lftp :~> set ftp:ssl-protect-data true
lftp :~> open ftps://ftp.box.com:990
lftp ftp.box.com:~> user yourusername@psu.edu
Password:
lftp yourusername@psu.edu@ftp.box.com:~> ls
...

 

when finish use exit to exit from lftp.

4: Copy a remote folder via FTP on the Linux command line using lftp (PDF)

 

References:

lftp Man page (PDF)

Using Box under Linux (PDF)

For more commonly used Linux commands, check my other posts at here  and here .