Using FTP from the Linux Command Line

Normally, FTP involves communication between your home or business computer and your server. Therefore, you probably use a graphical FTP program to handle all file transfers. In some instances, however, you will need to transfer files from your server to another server. For that, you will need to login to the second server through the command-line FTP of the first.

Starting ftp from the command line is simple. Just type ftp (or sftp for secure connections) followed by the host name you want to access.

ftp username@hostname.tld

It will prompt you for your password. Type it and then press Enter.

Once you are in, there are a variety of commands you should know.

ftp – Starts the FTP program.
open – Connects to a remote server. You can use it in combination with an address (i.e. open ftp.hostname.tld)
ls – Lists the files in a directory
cd – changes to the specified directory
get – downloads the specified remote file (i.e. get filename)
lcd – changes the current local directory (i.e. lcd /home/username)
send – uploads specified file (i.e. send server-doc)
quit – exits and returns the prompt to the local server

There are many more commands you can use in ftp. For a full list, type “help” from the ftp> prompt.

With sftp, you need to make sure you have SSH enabled and working on both systems. It will require SSH to connect, but the ftp commands will largely be the same and function the same way. As with ftp, just type “help” from the sftp> prompt for more information.