How to Transfer Files Using Command Line FTP (Windows)

We all know how to upload/download files using a FTP Manager client program available in our hosting control panel. You must have used FTP file manager/services like proftpd or FileZilla on numerous occasions. But what do you do if the hosting control panel does not offer you any FTP service? Or, at the worst, if your VPS package does not include any control panel altogether?

transfer files using command line ftpYou need not have to worry much because you can always rely on command prompt (or secure shell in case of Linux OS) to do the job for you. But how? Does it involve some kind of coding? Not exactly. You just need to instruct your server with a single line command and it would do the job for you instantly. As the attack surface is minimum when you use a core Windows component, hence transferring files via command line is more secure than using any common FTP client program.

This tutorial will show you how to use command line FTP to execute file transfer on any Windows server. Let’s learn how to upload/download files more securely using command line FTP on a Windows system.

STEP 1: Open Command Prompt

Log in to your system. Type ‘cmd’ on ‘Run’ input box and press the ‘Enter’ button to open a command prompt window. Alternatively, you can go to Start Menu -> All Programs -> Accessories and click on the ‘Command Prompt’ line item.

STEP 2: Initiate FTP Connection

To connect to your FTP server, you would need two things – 1. IP address or FQDN of the server and 2. a valid user account (unername/password). Run the following command to establish FTP connection –

ftp server-ip-address

STEP 3: Provide User Credential

Once the previous command is executed, a message will be displayed on your screen – ‘Connected to server-ip-address/FQDN’ and ask you to provide the user name. Provide a valid user name and press enter. Now you will be asked to provide the password. Type the password and press enter again. If you have provided the correct user credential, then a ‘Login successful’ message will be displayed.

STEP 4: Upload a File

Have you noticed that the command prompt directory has changed from your Windows drive [C:\user>] to [ftp>]? That means, FTP connection has been established with the FTP server.

Now we will try to upload a single file. ‘put’ command is used to upload a file in command line FTP. Before that you need to use ‘cd’ command to change the directory path to the folder where you are uploading the file. ‘cd’ stands for change directory.

Suppose you want to upload a text file named ‘test.txt’ from the ‘Files’ folder in ‘C’ drive on your local system to the directory ‘Uploads’ on the server. Then you need to use the below given commands –

ftp> cd uploads

It will show you a notification – “Directory successfully changed.” Now use ‘put’ command to upload the file in that directory.

ftp> put c:\files\test.txt

Once the file is uploaded, you will see a message like – “Transfer complete. ftp: XXXX bytes sent in Y.YYY Seconds XXXX.XXkbytes/sec.

Check for the uploaded file on the server computer inside ‘Uploads’ folder. That’s how you upload a file using Command Line FTP.

STEP 5: Upload Multiple Files

If you want to upload multiple files placed inside a folder, then you need to specify only the folder name and use ‘mput’ command with ‘*.file-type-extension’ [EX – *.txt]. It will upload all the files inside the folder which have that particular extension (all .txt files). So the command will be as given below –

ftp> cd uploads 

ftp> lcd c:\files\ 

ftp> mput *.txt

It will upload all the .txt files from c:\files folder to ‘Uploads’ folder on the server. Now let’s find out how the file download works.

STEP 6: Download a File

To download a file via Command Line FTP, we will be using the ‘get’ command. First you need to go to the directory where the file is kept on your FTP server. Suppose, you need to download the same file, ‘test.txt’ which you uploaded to the ‘Uploads’ folder in the previous step.

ftp> cd uploads

Again it will show you the message – “Directory successfully changed”. You can now use ‘get’ command to download the file to your local system.

ftp> get test.txt

The file ‘test.txt’ will now be downloaded to your computer’s default download folder. A confirmation message will also be displayed on screen. Go to your default download folder path to validate the result.

STEP 7: Download Multiple Files

To download multiple files from the server folder ‘Uploads’, you need to use the below given commands –

ftp> cd uploads 

ftp> mget *.txt

That’s it. Wasn’t it quite simple? Now you know how to transfer files using command line FTP. So next time when you don’t have an FTP program installed on your computer, trust command line to do it for you securely.

Leave a Reply