Using 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, FTP has been implemented across numerous platforms, based on the specifications of the protocol.

Logging in to an FTP server


Telnet is provided with various platforms, including UNIX, Windows 95, Windows NT, and Linux.
The command to initiate a Telnet session is usually:

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, be an FTP server.

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 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 the user has logged in, the FTP site waits for him/her to enter commands describing actions to perform.

FTP commands


As servers usually run on UNIX platforms (as they are better adapted to working on a network), FTP commands are typically UNIX commands.

The standard commands are:



<thDescription>

<tdAffiche l'ensemble des commandes supportées par le serveur FTP>

<tdPermet de connaître certains paramètres de la machine cliente>

<tdCette commande vous fait basculer du mode ASCII (envoi de documents textes) au mode binary (envoi de fichiers en mode binaire, c'est-à-dire pour les fichiers non texte, comme des images ou des programmes)>

<tdBascule du mode binary au mode ascii. Ce mode est le mode par défaut>

<tdPermet d'afficher le mode courant de transfert (binary ou ascii)>

<tdVous permet de réouvrir une session sur le site FTP en cours avec un nom d'utilisateur différent. Un nouveau mot de passe vous sera alors demandé>

<tdPermet de lister les fichiers présents dans le répertoire courant. La commande "ls -l" donne des informations supplémentaires sur les fichiers>

<tdAffiche le nom complet du répertoire courant>

<tdCette commande signifie >change directory, which is used for changing the current directory. The command "cd .." is used to access the parent directory

<tdLe commande >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.

<tdLe commande >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.

<tdCette commande permet de récupérer un fichier présent sur le serveur >
  • 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.

<tdCette commande permet d'envoyer un fichier local sur le serveur >
  • 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.

<tdFerme la session en cours et ouvre une nouvelle session sur un autre serveur FTP>

<tdFerme la session en cours, en laissant le logiciel FTP client actif>

<tdDéconnecte le logiciel client du serveur FTP et le met en état inactif>

<tdDéconnecte le logiciel client du serveur FTP et le met en état inactif>

Related :

This document entitled « Using 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.