Copy a remote folder via FTP on the Linux command line using lftp

Install lftp using:

apt-get install lftp

To start off with connect to the FTP server:


Login to the FTP server via lftp:

lftp> user yourusername
Password: (Enter your password)

As soon as you are logged in, you can list the remote folders using ls and list all available commands via help.

Let's assume that you have a folder htdocs, that you want to download from your ftp server, just do:

mirror htdocs

This will copy the htdocs folder from the remote ftp server to the local folder you are currently in.

If you want to do the opposite, so copying the local folder htdocs to the remote ftp server, just do:

mirror -R local-dir