Tap to Read ➤

List of FTP Commands

Padmini Krishna
Why should one use FTP? Apart from the obvious benefits it provides, of allowing remote authenticated access to files on a remote server, and their easy transfer irrespective of size, FTP is extremely easy to use; you just need to be well-versed with its commands. This story gives a complete list of all FTP commands, to make your task all the more simple.

Interestingly,

FTP (File Transfer Protocol), although extraordinarily useful, is not exactly the most secure method of file transfer available. However, it is possible to use FTP over protocols such as SSL (Secure Sockets Layer) and/or SSH (Secure Shell) to implement additional protection on the data transfer process.
** SSH is a secure way to acquire remote access to a computer, whereas SSL is a protocol that improves security at the transport layer of the network architecture by providing tunneling through a secure socket.
File Transfer Protocol is a wonderful tool.
It is essentially a networking protocol, that allows one to easily obtain the files he or she desires, such as media (for example, audio or video files), data (for example, .pdf files that span hundreds of megabytes), or even software.
It has a lot of practical uses, which include the fact that it breaks the limitations of email (and all the other file-sharing applications one might use), which does not allow users to send or receive a file bigger than a certain size, at one time, and also, it allows only authorized persons to access your stored files, that too from a remote location.
Another way to benefit from using FTP is to yourself access your personal files from a remote location by logging into your own computer with the help of it.
Of course, using FTP, just like any other internet-based service, comes with concerns of reliability, as it is evident that sending large amounts of data over long physical distances over a network would open up opportunities of hacking.
However, these issues can be worked around by implementing a few network security measures, such as encryption of data, or using FTP along with other secure protocols.
At the end of the day, the truth is, the beauty and simplicity of transferring your larger files entirely into another computer, that too located elsewhere, without having to use external memory devices, nor to trouble yourself with compressing the file so as to make it compatible with email, just by using FTP, is unsurpassed.
If you are now sold on the idea of using FTP to fulfill all your file-sharing needs, you would also be concerned about whether it is terribly difficult to figure out the nuances of FTP; whether you need to learn it, like a programming language.
The answer is, no, it is incredibly simple, all you need to do is to familiarize yourself with the commands so that you can use them as and when they are required. It is even more simple to pick up if you are already familiar with programming on UNIX.
This story provides you a complete list of all FTP commands, and what they are used for, so that irrespective of whether your system runs Windows, Linux, UNIX, or any other OS, you can easily make use of this handy method for transferring your files.

Getting Started: Logging into the Remote Computer

☛ Before beginning an FTP session, one needs to obtain basic information about the server host (to be read, from now on, as the remote computer of which you wish to access files) such as its domain name (if available) or at least its network address.
☛ Your own computer needs to be equipped with a suitable FTP client. This is important, especially if the computer you wish to connect to is running a different operating system. You will be typing in commands in the FTP client.
Different FTP client software are available for download (mostly they are free and open-source, but some are also chargeable), for example Filezilla, and generally, each has a UI-integrated login page, where one needs to enter server information.
☛ One can also connect to the FTP server by starting a session over one's browser. For this, you need to know the FTP address of the server. An FTP address has the following syntax:
ftp://username:password@ftp.serverhostname.com:21
where,
username and password - It may be optional to enter a username, and/or a password depending on the configuration of the FTP server. If it is not needed, the part of the address up till the '@' can be eliminated in the FTP address.
serverhostname - Either the server's hostname or its IP (network) address is mandatory.
21 → This value is the default TCP port number assigned to the FTP protocol. If you are using a different port number (in the event that you are using a different flavor of FTP), then you need to replace this value with the respective port number.
In any case, mentioning the port number is preferred so that your computer explicitly knows what port number to use, although mostly, people choose to eliminate this parameter.
☛ In the event that you do not have an FTP client software installed, the terminal (or the command prompt) can be used as your FTP client. Open the respective utility in your operating system.

In Windows, one can open the MS DOS command prompt by opening the Start Menu, and typing "cmd" in the Search Box, followed by the Enter ↵ key.
If you are using a Mac computer, you can find the Terminal inside the Utilities folder in the Applications menu.

In Linux-based OS computers, one can open the Terminal by pressing the Ctrl, Alt, and T keys.

Now, in the terminal (or prompt) type the following
C:\>ftp serverhostname.com
Where serverhostname.com refers to either the domain name of your server, or its IP address.

After this step, your client will prompt you for the username and/or password, if the server requires it.
One can log in to the FTP server in the anonymous mode too, wherein although files can be downloaded from it, one can neither make changes in the directory structure, nor modify any files. If your server supports anonymous login, it will specify this before asking you for a username and password.
If you wish to log in as an anonymous client, you need to enter your username as "anonymous", and simply press the Enter ↵ key when you are asked for the password.

C:\>ftp serverhostname.com
Connected to serverhostname.com.
220 You are allowed to login as an anonymous user.

User username

331 Password required for serverhostname.com.
Password:

230 User serverhostname.com logged in.

ftp:\>_

☛ Now that you have successfully logged into the desired FTP server, you can now use any of the FTP commands to browse or navigate through and return from the directories (or folders) available on the server, as well as download and upload files.

The List of Commands

Tip:- Most of the commands are valid across platforms (i.e. irrespective of whether you are running FTP on your Linux/Unix Terminal or on Microsoft Windows' Command Prompt. 
If you are unsure if a command is valid on the platform that you are using, enter "?" at the FTP:\> prompt, and you will be provided with a complete list of commands that your terminal/command prompt supports. Typing "?" followed by a command you are unsure about will give you its description.
If you are using a GUI-based FTP client program, you have nothing to worry about, because most client software allow you the luxury of not even having to actually type any commands at all! Some client software, although prettier to look at in comparison to the drab black (or white) screen of the terminal, may only support an interactive FTP session.
And if you are a coding buff and prefer to actually use the command line interface, then too, you truly need to have competent knowledge of all the FTP commands. We have compiled a list of all the commands that can be used across various operating systems.
  • !- If an exclamation point (!) is typed before a command, then instead of on the remote server system, the command will be executed on your own (local host's) system.
  • append- With this command, using the current file setting, one can add a file that is located on one's own (local host) computer to a file located on the remote server.
  • ascii- Since files can be transferred in either ASCII mode (as in the case of text files) or binary mode (as in the case of executable files, or programs), this command can revert the file transfer mode to the ASCII mode, which is also the default.
  • bell- With this command, a bell can be scheduled to ring after each file transfer. It is toggled off by default.
  • binary- As mentioned, there are two file transfer modes; ASCII and binary. By using this command, one can change the current file transfer mode to binary.
  • bye- This command can be used interchangeably with the 'quit' command to terminate the FTP session with the remote server, along with closing the FTP prompt.
  • cd- Just like with MS DOS, the 'cd' command stands for Change Directory, and it can be used to navigate into folders in the remote computer. When the command is followed by the folder name, its effect is the same as double-clicking on a folder in Windows Explorer.
  • close- Only the FTP session and not the prompt application entirely, can be ended if this command is used.
  • debug- The function of debugging all sent commands can be toggled on or off with the help of this command; however, the default setting is off.
  • delete- This function can be used when one wants to delete a single file on the remote server computer. The filename should follow the command. A different command is to be used if you need to delete more than one file at a time.
  • dir- When you wish to know contents of a folder, you can use this command. A list of all the files within a directory will be displayed if this command is followed by the respective directory's name.
  • disconnect- This command ends the connection with the remote server, but it does not terminate the session, nor cause you to exit from the terminal application.
  • get- This is the command that is used to copy a single file located on the server on to one's own computer. This command needs to be followed by the name of the remote file as well as the name that you wish for it to be saved with on the local host.
  • glob- This is another toggle command. When switched on, wildcard characters can be used in the name of local file names or directory names.
  • hash- Yet another toggle command, the 'hash' command toggles the function of marking every block of data (of 2KB) that is transferred, by printing a "#" (hash) sign for it. It is off by default.
  • help- This function can be used alternatively with the question mark (?) command.
  • lcd- Suppose you wish to change the directory on your local computer (otherwise the path where your downloaded files will get saved will be the same as the path before you started the FTP session), then you can type this command followed by the directory you wish to shift to.
  • literal- This command is used to communicate certain arguments (parameters) to the remote server, and elicit a response from the server. The command is followed by the verbatim.
  • ls- While the 'dir' command gives you all the information you can get about the directory's sub-folders and files, the 'ls' command, which has a similar syntax, will give you the same information, abbreviated, in list form.
  • mdelete- This command extends the functionality of the 'delete' command to more than one file located on the remote server. One needs to enter the names of all the files one wishes to delete after the command.
  • mdir- If you wish to extend the functionality of the 'dir' command to multiple folders, you can use 'mdir', which can give you information about the contents of more than one directory located on the remote server at a time.
  • mget- If you wish to download (copy from the server computer to your own) more than one file at a time, the 'mget' function should be used. Specify the names of the files to be copied after the command.
  • mkdir- This command can be used to create a directory on the remote system.
  • mls- This command extends the functionality of the 'ls' command to multiple folders located on the remote server host.
  • mput- With the current transfer type setting retained, this command allows you to upload more than one file that is located on your computer, on to the remote server.
  • open- When an FTP session is running, one can begin a connection to any remote server computer using this command. In the syntax, apart from the command and either the domain name of the server or its IP address, one can also mention the port number to be used to establish this connection.
It is compulsory to specify the port number if you wish to connect to another server while one connection is still valid, because the default port, 21, is already in use.
  • prompt- This command acts as a toggle switch for the prompting function, whose effect is especially seen while using commands dealing with multiple files, because it will prompt the user for confirmation before the action is performed on each file separately. By default, the function of prompting is on.
  • put- This command is used to copy (upload) a single file to the remote server computer. The name of the file that you wish to copy needs to follow the command.
  • pwd- pwd is a UNIX-based command that stands for Print Working Directory. It returns the path of the current folder that is open on the remotely-located server that you are connected to.
  • quit- This command can be used interchangeably with 'bye' to close the terminal (command prompt) and simultaneously also end the FTP session and break any connection with a remote server.
  • quote- This command can be used interchangeably with 'literal' to send arguments or verbatim to the remote server. It also follows the same syntax.
  • recv- This command can be used interchangeably with the 'get' command to download a file from the remote server onto one's own computer.
  • remotehelp- This command gives you information about commands that can be used with the remote server. If a specific command is typed following 'remotehelp, one can obtain information about that command.
  • rename- This command can be used to rename a file that is located on the remote server computer. The command needs to be followed by the name of the file that you wish to alter, after which you should type the new name you wish to assign to it.
  • rmdir- This command can be used to delete an entire directory and all its contents that is located on the remote server host. The command needs to be followed by the directory's name.
  • send- Identical to the 'put' command and following the same syntax, this command uploads a file onto the remote server computer.
  • status- This command can be used to obtain information about the current status of all FTP connections and settings that can be toggled.
  • trace- This command can be used to toggle the function of packet tracing, or displaying the route, for each packet sent or received during the FTP session. By default, packet tracing is off.
  • type- This command can be used to set the file transfer type implicitly. There are two types that are supported; ASCII, and binary. You need to specify the type after the command.
  • user- If you wish or have to log on to the remote server as a specific user, use this command followed by the username, password, and account type; the last two being optional.
However, if the server computer has been configured in such a way that it requires a password and/or the account type to be specified before permitting a user to log on, you will be prompted for those values.
So now, you need not worry even if the system you are using does not have an FTP client software available on it, as, if you are familiar with the most essential FTP commands, you can effortlessly use your computer's terminal or MS DOS prompt as an FTP client. We hope you found this useful.