FTP commands

December 2016

The FTP protocol

FTP (File Transfer Protocol) is a protocol — meaning a standard language that lets two machines communicate — used so that computers of different types (or with different operating systems) can transfer files over a network that uses TCP/IP.

FTP operates in a client/server environment, meaning that the remote machine is configured as a server, and consequently waits for the other machine to request a service from it. In UNIX, the service is provided by what is called a daemon, a small task that runs in the background. The FTP daemon is called ftpd.

There are many FTP client programs, some of which are run from a command-line (such as the command ftp, a standard installed in many operating systems), but a large majority allow the user to manipulate files via a graphical interface (such as CuteFTP), which makes file transfers more user-friendly.

The FTP protocol is used for transferring one file at a time, in either direction, between the client machine (the one which initiated the connection, i.e. the calling machine) and the server machine (which provided the FTP service, i.e. the called machine). The FTP protocol can also perform other actions, such as creating and deleting directories (only if they are empty), listing files, deleting and renaming files, etc.

Protocols and implementation

Do not confuse the separate concepts of the protocol and its implementation! A protocol is a set of rules and procedures which have been defined in order to standardize communications, while the implementation is software programming which follows (more or less) the protocol's recommendations.

For this reason, the "ftp" command has been implemented across numerous platforms, based on the specifications of the FTP protocol.

Logging in to an FTP server

The command "ftp" is available across various platforms, including UNIX, Windows and Linux. The command initiates an FTP session, and is usually run as follows:

ftp server_name

server_name represents the name or IP address of the remote machine that the user wants to connect to. The target machine must, of course, have an FTP service.

Once the connection has been initialized, a few lines of text appear on the screen. The first line lets you know that you have connected to an FTP server, the next lines welcome you to it, and may indicate which kind of FTP site it is (i.e, what sort of files it hosts or which organization owns it), or instructions for users.

In FTP, each line begins with a number that represents either success or failure. For a welcome message, the line might be preceded by the number 220, which means "the service is ready for the new user."

The server asks you to enter your user name (also called a login or identification), in order to set access rights (such as read/write privileges). After the user name has been accepted, a line beginning with the number 331 invites you to input your password, which is masked, meaning that it doesn't appear on the screen.

In some cases the server may be public, in which case you can log in anonymously, and you will therefore have to log in as "anonymous" (or "guest"). For public servers, custom dictates that the user enters his/her email address as the password, but you can enter whatever you choose.

Once the password has been accepted, a message will show if the connection has been established or not, in which case a reason will be given (for example, the site may have reached its maximum number of users allowed at a time, in which case the message "No more users allowed" appears).

Once logged in, the FTP site waits for the user to enter commands describing actions to perform.

FTP commands

The normal FTP commands are:

Order Description
help Displays all commands supported by the FTP server.
status Used for showing some of the client machine's settings
binary This command switches you from ASCII mode (sending text documents) to binary mode (sending binary files, i.e. non-text files like images or programs)
ascii Switches from binary mode to ASCII mode. This is the default mode.
type Displays the current transfer mode (binary or ASCII)
user Allows you to log in to the current FTP server again using a different user name. You will then be requested to enter a new password.
ls Lists all files found in the current directory. The command "ls -l" gives additional information on the files.
pwd Displays the full name of the current directory
CD The command stands for change directory, and is used for changing to a different directory. The command "cd .." is used to access the parent directory
mkdir The command mkdir (in UNIX, or md in Microsoft) is used for creating a directory within the current directory. The use of this command is reserved for users with access allowing it.
rmdir The command rmdir (in UNIX, or rmd in Microsoft) is used for deleting a directory within the current directory. The use of this command is reserved for users with access allowing it.
get This command is used to retrieve a file found on the server.
  • If the command is followed by a file name, the remote file will be transferred to the local machine, into the current local directory
  • If the command is followed by two file names, the remote file (the first name) is transferred to the local machine in the current local directory, with the specified file name (the second name)
If the file name contains spaces, be sure to enter it within quote marks.
put This command is used to send a local file to the server
  • If the command is followed by a file name, the local file will be transferred to the remote machine, into the current remote directory
  • If the command is followed by two file names, the local file (the first name) is transferred to the remote machine in the current remote directory, with the specified file name (the second name)
If the file name contains spaces, be sure to enter it within quote marks.
open Logs out and opens a new session on another FTP server
close Logs out, leaving the FTP client active
bye Disconnects the FTP client from the server and puts it into inactive mode
quit Disconnects the FTP client from the server and puts it into inactive mode

More information


Related :


Comandos FTP
Comandos FTP
Die FTP-Befehle
Die FTP-Befehle
Les commandes FTP
Les commandes FTP
I comandi FTP
I comandi FTP
Comandos FTP
Comandos FTP
This document entitled « FTP commands » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.