Linux Commands

FTP Client Linux Command-Line Tutorial

FTP (File Transfer Protocol) is a protocol for transferring files over a network. In the past, FTP was the preferred method for transferring the data between computers. However, this is no longer the case. The main problems that FTP used to have are solved by the newer protocols and programs.

What Will We See Here?

In this article, we will explore how to use the ftp command for remote system connection, file transfer, and managing the remote and local files and directories.

What Will We Need?

  1. Access to a remote FTP server from the local system. To keep it simple, we use a VirtualBox environment.
  2. FTP components are installed on both the local and remote systems.

NOTE: Since the FTP traffic is unencrypted, it is therefore an unsecured service. We thus recommend not to use it to transfer sensitive data over the internet and other unreliable networks.

FTP Command Syntax

The FTP command has the following syntax:

ftp [options] [IP]

Here, [IP] denotes the IP address of the target remote system.

The FTP command uses the FTP protocol to connect a system to another system, which is usually a remote server, using the FTP protocol.

After a connection is established, users can also transfer files between the connected systems and manage the files and directories on them.

Creating an FTP Connection

We can create an FTP connection to a remote server using it’s IP address along with the FTP command:

ftp [IP]

For example, to connect to a remote server with the IP address, run the following command:

$ ftp

When prompted, enter the credentials for the FTP user. Let’s see a live example of logging into an FTP server.

FTP Logging a Server

As soon as we establish a connection to the FTP server, we need to enter the username and the password to log in:

After entering the right credentials, we should be on the FTP interface:

Alternatively, we can first run the FTP command. Then, use the following command on the FTP interface:

ftp> open <Target_IP>

From this interface, we can interact with the local machine as well as the remote server. We will soon see this in the following sections.

Listing the FTP Commands

Once we are inside the FTP interface, we can see and use all its commands. Let’s see all the supported commands by simply entering the “?”:

ftp> ?

This represents us with many commands like dir, ls, disconnect, and so on. Let’s take a hand on a bunch of them.

Listing the Directory Contents

Let’s first see how we can list the content of the current directory on the remote system like the FTP server. Simply use the dir command here:

ftp> dir

As mentioned earlier, we can manage the local machine from the remote machine. Let’s see how we can display the contents of the local directory:

ftp> !ls

The previous command displays the contents of our local system. To get more detailed listing, we can run the following command:

ftp> !ls -l

Similar to pwd which displays the current directory path, we can use the lcd command to display the same local path from the remote machine:

ftp> lcd

Changing the Current Directory

To navigate to the other directories on the remote server, we can use the usual cd command. For example, from the remote directories that are listed previously, we can change to the directory upload:

ftp> cd upload

Uploading the Files

We can use the put command to send a single file to a remote server. Let’s see how to do this by simply uploading a from_local.txt local file:

ftp> put from_local.txt

After the command is successful, we will see a message like “Transfer complete”. By default, the file lands in the current directory on the remote server. However, we can customize this location by specifying the full path:

ftp> demo.txt /path/to/the/destination/directory/desired_filename

We can also use the dot (.) separator to denote the current path:

ftp> demo.txt ./…./destination/directory/desired_filename

Let’s now see how to deal with multiple file uploads. We can use the FTP mput command to upload multiple files. For this, we need to specify the file names separated by spaces:

ftp> mput file3 file2

Interestingly, we can use the wildcards here if the file names share something in common. For example, to upload all the files with the name file but with different types, we can use the following command:

ftp> mput file.*

Before you can upload the files, you have to enter “yes” to confirm your action.

Downloading the Files

Let’s see how to download the files from the remote server to the local system. Instead of using put, we need to use its antonym like get. For instance, we can download/send a file, say file3.txt, to the local system as follows:

ftp> get file3.txt

As seen in the uploaded scenario, we can also download a file to the directories other than the current directory on the local system. Just specify the full path on the local system:

ftp> get file6.txt /path/on/local/directory/of/client/name_of_file

Similar to mput, we can use the mget command to download multiple files. Again, let’s see it in action:

ftp> mget file5.txt file6.txt

Also, the wildcards can simplify our work for similar types of files:

ftp> mget *.txt


In this article, we cover a high-level overview of the FTP command on Linux. Besides the FTP client, there are other FTP clients for Linux such as Lftp, FileZilla, etc.

About the author

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn