Tutorial For Working With The FTP Command Line

Check out our tutorial for getting started with the FTP command line. We offer easy to follow step-by-step instructions with screenshots and examples.

  1. Blog

This tutorial is for those who 1) understand the vulnerabilities of FTP but still want to learn how it's used AND 2) prefer doing things on the FTP command line.

The screenshots you'll be seeing here were taken from a Linux machine. However, the commands are the same whether you use Windows command-line, Solaris, OS X, UNIX, or any other operating system that supports FTP.

FTP Connection And Logging Into The Server

To start using FTP on the command prompt, launch a terminal screen and then type ftp. After pressing the Return key, you should see a prompt labeled ftp>. This means the system is ready to accept FTP commands. Enter the following command:

open [the hostname or IP address of your ftp server]



After pressing the return key, you should then be asked to enter your username on the FTP server. Type it in and then press the return key.

Next, you'll be asked to enter that username's corresponding password (pwd). Again, enter that and then hit return. If the login was a success, you should get a message saying you're now logged in.

Another way to do this would be to type in ftp followed by the FTP server's hostname or IP address, like so:

As soon as you're inside the FTP user interface (marked by the "ftp prompt"), you can request for a list of supported commands by entering the question mark symbol ?.

Let's try some of those commands on that list (mkdir, delete, rename, rmdir, glob, verbose, etc).

Listing The Contents Of The Remote Directory

To display the contents of the current remote directory on the FTP server, just enter the command:


Listing The Contents Of The Local Directory

The command for listing the contents of the local directory is a little bit different. For that, you'll need to run a local shell command. But before you can do that, you'll have to escape to the shell. This can be done with the exclamation mark !.

In Linux, the command to list the contents of a directory is ls. So,


will list all the contents of the local directory.

Note that !ls won't display the contents in the same format as the dir command shown earlier. To display contents in a format similar to the dir command, use the -l option. So the complete command would be:

!ls -l

Displaying The Current Local Directory

Interestingly, it's possible to display the current local directory (not its contents) without escaping to the shell. You can simply enter the lcd command like this:

Changing Your Local Working Directory

To change your working directory in the local machine, just add the directory path to the lcd command:


If the directory you want to change into is just a subdirectory of your current working directory, then you can simply enter that directory's name like this:

Changing Your Remote Working Directory

The command for changing your remote directory is quite similar to the previous one. Just remove the l ("l" apparently stands for "local"). The screenshot below shows how we changed into the directory named "remotedir1".

If you scroll back up to the section "Listing the contents of the remote directory" and view the screenshot, you'll realise that remotedir1 is actually a subdirectory of that current working directory. Thus, we simply entered cd remotedir1 instead of typing in the complete path.

We ran the dir command just to show you the contents of that new working directory.

Uploading A File

To upload a file using FTP, you use the put command. Here's the put command uploading a file named main.txt. Note that this command will simply upload the file into the current remote working directory. The succeeding section discusses how to upload a file to a different directory.

Uploading A File To A Different Directory

If you're familiar with the directory structure of the account on the remote server and want to upload a file to a directory that's not the working directory, you can specify the directory path in the put command like this:

Notice that, because our destination directory "remotesubdir1" is just a subdirectory of the current remote working directory, we just prefixed that directory with the dot (.). Dot (.) means "current directory".

Notice also that we renamed the newly uploaded file to mainupload.txt. If you want to retain the same name, just use the same name.

Uploading Multiple Files

The FTP command for uploading multiple files is mput. You can use mput with several space-separated filenames. This is what you should use if the files you want to upload have nothing in common, like say the filename extension or the first three characters or the last two characters, etc.

Notice that, before each file is uploaded, you'll be prompted for a confirmation. Just type in y (for yes) to confirm.

Uploading Multiple Files Using Wildcards

In cases where the files you want to upload have something in common, you can shorten the command by using wildcard characters. For example, the mput command below uploads all files with the .txt extension.

Just like in the previous mput command, you'll be asked to confirm before each file is uploaded.

Downloading A File

The syntax for downloading a file is similar to the syntax for uploading, except that the command is get instead of put. That should be easy to remember, right? Here's an example showing how that command is executed.

Downloading A File To A Different Directory

Here's how you download a file to a directory other than the current directory. You'll need to specify the complete path, including the new filename (if you want to change the filename upon download).

Downloading> Multiple Files

This is similar to the syntax for uploading multiple files, except that it uses the mget command instead of mput command. Again, you need to confirm each upload with a y (yes).

Downloading Multiple Files Using Wildcards

Here's an example showing how to download multiple files using a wildcard.

There are several commands out there but this should be enough to get you started.

Get Your Free Trial

Would you like to try this yourself? JSCAPE MFT Server is platform-agnostic and can be installed on Microsoft Windows, Linux, Mac OS X and Solaris, and can handle any file transfer protocol as well as multiple protocols from a single server. Additionally, JSCAPE enables you to handle any file type, including batch files and XML. Download your free 7-day trial of JSCAPE MFT Server now.

Download JSCAPE MFT Server Trial

Related Content

How To Auto Upload Files To A Server From A Local Directory

How To Protect FTP Passwords From Brute Force Attacks

Understanding Key Differences Between FTP, FTPS And SFTP

FTP Binary And ASCII Transfer Types And The Case Of Corrupt Files