File Transfer Protocol – FTP

What is FTP

File Transfer Protocol (FTP) is a standard network protocol used to copy a file from one host to another over a TCP/IP-based network, such as the Internet. FTP is built on a client-server architecture and utilizes separate control and data connections between the client and server. FTP users may authenticate themselves using a clear-text sign-in protocol but can connect anonymously if the server is configured to allow it.
The first FTP client applications were interactive command-line tools, implementing standard commands and syntax. Graphical user interface clients have since been developed for many of the popular desktop operating systems in use today.

The objectives of FTP are to:

  • promote file (programs or data) sharing
  • efficiently transfer data from one computer to another
  • encourage indirect or implicit use of remote computers
  • provide a common platform for file storages among different hosts

FTP sites

FTP sites are storehouses of hundreds to thousands of files – programs, data, music, video etc. In order to upload or download a file from an FTP site, you need to know the login details – the FTP username and FTP password. Once connected, you can transfer files using the binary or ASCII mode. The binary mode is used for binary files like executable programs, music, images, video etc. while the ASCII mode is employed for plain text files such as those created in Notepad, vi etc.

What is anonymous FTP?

On connection to an FTP site or FTP server, you would typically be asked the login details – a username and password. However, some severs enable what has come to be known as anonymous FTP. On Anonymous FTP servers you can log in with ‘anonymous’ as username and your email as password. You would then have access to all the data which has been placed in the anonymous FTP section.

FTP and web sites

The File Transfer Protocol is generally used by web developers to upload web sites to the host – the computer that stores the web site. For example, if you buy a web hosting package, the company would provide you with a username and password with which you’ll connect to the FTP server to transfer your files.

FTP on your desktop

FTP is built into the Unix system and can be accessed by typing ftp at the Unix prompt.
FTP is also available in Windows. You need to open an MS-DOS window and type ftp at the Dos prompt. The prompt will change to an FTP prompt. You can open an FTP site with the ‘open’ command. Type ‘quit’ to come back to the Dos prompt. To get help, type ‘help’ or ‘?’ at the FTP prompt. This will list the commands available on your system – check the image below.

To get help on a specific command, type help [Command name] or? [Command name]. So if you need help with the verbose command, type help verbose or? verbose.

Transfer Files in a Heterogeneous Host Environment

• Due to multiple hardware types and operating systems file are converted to four environmentally neutral data type for transport and the converted to local types at the destination
– ASCII A NVT-ASCII
– EBCDIC E EBCDIC Text
– IMAGE I Raw binary, series of octets
– LOCAL L Raw binary using a variable byte size
• Client responsibility to tell server data type to use
• Default data type, unless otherwise specified is ASCII

File Structures

• Operating System store files in different structures
• FTP defined file structures for transporting files
– File F Unstructured, sequence of bytes
– Record R Series of records
– Page P Series of data blocks (pages)
• Default file structure is File (F)
• File Structure specified using STRU command

FTP Transmission Modes

• Mode is used to specify additional coding or sequencing performed on data
• Independent of data type and file structure

Stream               S stream of bytes, if record structure EOF sent as record indication; if file  eof indicated by closing stream
Block                  B file sent as sequence of blocks  preceded by header info allows restart of an interruped transfer
Compressed      C data compressed using run length encoding

FTP Commands

USER R  User name, userid for access control
PASS O  Password for access control
ACCT O  Account info
CWD O  Change working directory
CDUP O  Change to parent directory
SMNT O  Structure mount, mount a different file system
QUIT R  informs server that client wants out
REIN O  restarts session at authentication phase
PORT R  Host addr and data port to use
PASV O  Passive; informs server that client will contact to set up data Connections, ask server to sent port info
TYPE R  Data type, type of subsequent transfers
STRU R  File structure
MODE R  Transfer mode
RETR R  Retrieve, download the file from server
STOR R  Store, upload the specified to server
STOU O  Store unique, same as store but server picks unique file name
APPE O  Append, upload file to server, if file name exists, append the upload
ALLO O  Allocate, sometimes used to preallocate space
REST O  Restart, restart an interrupted transfer
RNFR O  Rename file from filename
RNTO O  Rename file to
ABOR O  Abort, ask server to abort last command
DELE O  Delete specified file
RMD O  Remove directory
MKD O  Make directory
PWD O  Print working directory
LIST O  Request directory listing
NLST O  Request just a file name list
SITE O  Site parameters, allow client to specify site specific options and parameters
SYST O  request server operating system
STAT O  Request server to send status of current xfr
HELP O  general and command specific
NOOP R  ask server to send a positive reply

File Transfer Protocol and the browser

Modern browsers allow you to access sites using FTP. For example, if I need to connect to this web site from Internet Explorer (version 6) on the Windows XP system, I can simply type in ftp://www.webdevelopersnotes.com in the address bar. A login window then pops up (see below), in which I need to type in the username and password to connect to the host. I can then transfer files using the familiar drag-drop method. So one can actually work in the user-friendly environment of the operating system without knowing all the arcane FTP commands! Now isn’t that cool?

FTP clients

If you plan to FTP on a regular basis, I suggest you use an FTP Client – a dedicated program for FTP. There are many FTP clients available (and some of them are freeware). The interface of each program varies, but the information required is almost the same. You should know your username and password of the site (if it is not anonymous FTP) and the server address.
Here is a list of some FTP clients that I have used – FTP clients or FTP programs. I have also put a thorough tutorial on using FTP with a popular and free FTP client – Using FTP with FTP Explorer.

Using FTP with FTP Explorer

A good web hosting service provides you with an FTP account through which you can maintain and administer your site. Under Windows, FTP connection can be established via the DOS prompt, but an FTP client presents a more user friendly interface. Here, we look at FTP Explorer, which is a freely available FTP client for the WIndows system. You can download it from www.ftpx.com.
Once you install this program, it can be accessed from the Programs menu. The FTP Explorer might not have some great features found in commercially available software such as CuteFTP or WS-FTP but it serves its purpose well and is quite fast.

Step 1 – Making an account

On starting FTP Explorer, you are presented with the Connect window. Here you can specify the various details of the server you plan to connect to.
This window with all its text fields might look daunting at the first glance. Here is a description of the common fields:
• Profile name: This allows you to name the connection and can be anything of your chosing. Make it simple and easy to remember. So for www.fontmagic.com, I use Fontmagic as the profile name.
• Host address: The address of your server like www.fontmagic.com.
• Port: Leave this at 21 unless your server uses a different port (unlikely). Also, leave the two checkboxes for Use PASV Mode and Use Firewall, unchecked.
• Login: Type your login name and click on the Anonymous checkbox to remove the check mark.
• Password: Type your password
• Initial Path: You can remove any value if it exists.
• Attempts: Leave it at its default value of 1.
• Retry Delay: Leave this at its default value of 10.
• Download Path: This field lets you specify the directory in which any downloaded files will be stored. Leave it blank or select a download directory.
• Description: Allows you at add some explanatory text for the connection.
• Cache data between sessions: Can be left blank.
Once you have filled all the required fields, click on the Add button to add this account to the list on the left.
The program stores all what you enter in the text fields in its database, so you don’t have to repeat the process for the same server the next time.

 Step 2 – Establishing a connection

Start an Internet connection, if you are not connected.
In FTP Explorer, select the account name from the list on the left in the Connect window and click on the Connect button.
The program will try to find the host and establish a connection. As the program sends commands to the host the information is displayed at the bottom. Once this is done successfully, the right window displays the listing of directories and files found at the server while the left displays the directory tree. You should also get a “Transfer complete” message at the bottom.

Step 3 – Changing Directory

The right window displays the list of directories found on the server. To open a directory, double-click on it. FTP Explorer will now try to retrive the directory information from the server and display it in the right window.

You’ll notice that the directory tree in the left window expands and to display the listing of the directory in use, click on the ‘+’ sign in front of the directory name. Also, the path of the present working directory is at the top of the right window.

What are the major difference between telnet and ftp?

  • FTP is a protocol used specifically for transferring files to a remote location, while Telnet allows a user to issue commands remotely.
  • FTP can be used with a command line, a dedicated application, and even with most web browsers, while Telnet is restricted to the command line.
  • There are ways to use FTP in a secure environment, while Telnet will always be unsecured.
  • FTP is a well-known and reliable method of uploading files to web servers, while Telnet is now commonly used in diagnosing network services.
  • Telnet is like a remote Command Prompt, where you can issue various commands to your remote machine.
  • FTP is like a remote Explorer, where you can drag and drop all your files. FTP is one of the methods that you can use to download and share porn to your friends.

Note that neither Telnet nor FTP are applications. Instead, they are standard methods, or *protocols* for talking to other machines.