Provided by Colasoft Co., Ltd.

FTP ( File Transfer Protocol )

Home > Protocols > FTP Update: 2006-10-16 13:34:15    I have words to say about this protocol
On this page
SUMMARY
Protocol : File Transfer Protocol
Protocol suite : TCP/IP
Layer : Application Layer
Type : File transfer protocol
Ports : 20 (TCP) default data
21 (TCP) control
URI : ftp:
Working groups : Ftpext, Extensions to FTP
DESCRIPTION
File Transfer Protocol (FTP), a standard Internet protocol, is the simplest way to exchange files between computers on the Internet. Like the Hypertext Transfer Protocol (HTTP), which transfers displayable Web pages and related files, and the Simple Mail Transfer Protocol (SMTP), which transfers e-mail, FTP is an application protocol that uses the Internet's TCP/IP protocols. FTP is commonly used to transfer Web page files from their creator to the computer that acts as their server for everyone on the Internet. It's also commonly used to download programs and other files to your computer from other servers.

As a user, you can use FTP with a simple command line interface (for example, from the Windows MS-DOS Prompt window) or with a commercial program that offers a graphical user interface. Your Web browser can also make FTP requests to download programs you select from a Web page. Using FTP, you can also update (delete, rename, move, and copy) files at a server. You need to logon to an FTP server. However, publicly available files are easily accessed using anonymous FTP.

Basic FTP support is usually provided as part of a suite of programs that come with TCP/IP. However, any FTP client program with a graphical user interface usually must be downloaded from the company that makes it.

The FTP specification says that by default, all data transfers should be over a single connection. An active open is done by the server, from its port 20 to the same port on the client machine as was used for the control connection. The client does a passive open. For better or worse, most current FTP clients do not behave that way. A new connection is used for each transfer; to avoid running afoul of TCP's TIMEWAIT state, the client picks a new port number each time and sends a PORT command announcing that to the server.

FTP uses the Telnet protocol on the control connection.


Command-line Options
As you're starting the program from a DOS prompt:ftp [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [computer]

Option

Description

-v

Suppresses verbose display of remote server responses.

-n

Suppresses auto-login upon initial connection.

-i

Turns off interactive prompting during multiple file transfers.

-d

Enables debugging, displaying all ftp commands passed between the client and server.

-g

Disables filename globbing, which permits the use of wildcard chracters in local file and path names.

-s:filename

Specifies a text file containing ftp commands; the commands will automatically run after ftp starts. No spaces are allowed in this parameter. Use this switch instead of redirection (>).

-a

Use any local interface when binding data connection.

-w:windowsize

Overrides the default transfer buffer size of 4096.

computer

Specifies the computer name or IP address of the remote computer to connect to. The computer, if specified, must be the last parameter on the line.




FTP Commands

Command

Description

!

Runs the specified command on the local computer

?

Displays descriptions for ftp commands

append

Appends a local file to a file on the remote computer

ascii

Sets the file transfer type to ASCII, the default

bell

Toggles a bell to ring after each file transfer command is completed (default = OFF)

binary

Sets the file transfer type to binary

bye

Ends the FTP session and exits ftp

cd

Changes the working directory on the remote computer

close

Ends the FTP session and returns to the command interpreter

debug

Toggles debugging (default = OFF)

delete

Deletes a single file on a remote computer

dir

Displays a list of a remote directory's files and subdirectories

disconnect

Disconnects from the remote computer, retaining the ftp prompt

get

Copies a single remote file to the local computer

glob

Toggles filename globbing (wildcard characters) (default = ON)

hash

Toggles hash-sign (#) printing for each data block transferred (default = OFF)

help

Displays descriptions for ftp commands

lcd

Changes the working directory on the local computer

literal

Sends arguments, verbatim, to the remote FTP server

ls

Displays an abbreviated list of a remote directory's files and subdirectories

mdelete

Deletes one or more files on a remote computer

mdir

Displays a list of a remote directory's files and subdirectories

mget

Copies one or more remote files to the local computer

mkdir

Creates a remote directory

mls

Displays an abbreviated list of a remote directory's files and subdirectories

mput

Copies one or more local files to the remote computer

open

Connects to the specified FTP server

prompt

Toggles prompting (default = ON)

put

Copies a single local file to the remote computer

pwd

Displays the current directory on the remote computer (literally, "print working directory")

quit

Ends the FTP session with the remote computer and exits ftp (same as "bye")

quote

Sends arguments, verbatim, to the remote FTP server (same as "literal")

recv

Copies a remote file to the local computer

remotehelp

Displays help for remote commands

rename

Renames remote files

rmdir

Deletes a remote directory

send

Copies a local file to the remote computer (same as "put")

status

Displays the current status of FTP connections

trace

Toggles packet tracing (default = OFF)

type

Sets or displays the file transfer type (default = ASCII)

user

Specifes a user to the remote computer

verbose

Toggles verbose mode (default = ON)




FTP Reply Rode Values

Code

Meaning

Description

1yz

Positive Preliminary reply.

An initial response indicating that the command has been accepted and processing of it is still in progress. The user should expect another reply before a new command may be sent.

2yz

Positive Completion reply.

The command has been successfully processed and completed.

3yz

Positive Intermediate reply.

The command was accepted, but processing of it has been delayed, pending receipt of additional information. This type of reply is used in the middle of command sequences. For example, it is used as part of the authentication sequence after receiving a USER command but before the matching PASS command is sent.

4yz

Transient Negative Completion reply.

The command was not accepted and no action was taken, but the error is temporary and the command may be tried again. This is used for errors that may be a result of temporary glitches or conditions that may change; for example, a file being ˇ°busyˇ± due to another resource accessing it at the time a request was made for it.

5yz

Permanent Negative Completion reply.

The command was not accepted and no action was taken. Trying the same command again is likely to result in another error. For example, a request for a file that is not found on the server would fall into this category, or sending an invalid command like ˇ°BUGUˇ±.

x0z

Syntax.

These replies refer to syntax errors, syntactically correct commands that don't fit any functional category, unimplemented or superfluous commands.

x1z

Information.

These are replies to requests for information, such as status or help.

x2z

Connections.

Replies referring to the control and data connections.

x3z

Authentication and accounting.

Replies for the login process and accounting procedures.

x4z

Unspecified

x5z

File system.

These replies indicate the status of the Server file system vis-a-vis the requested transfer or other file system action.




FTP Reply Codes

Command

Description

110

Restart marker reply.

120

Service ready in nnn minutes.

125

Data connection already open; transfer starting.

150

File status okay; about to open data connection.

200

Command okay.

202

Command not implemented, superfluous at this site.

211

System status, or system help reply.

212

Directory status.

213

File status.

214

Help message.

215

NAME system type. Where NAME is an official system name from the list in the Assigned Numbers document.

220

Service ready for new user.

221

Service closing control connection. Logged out if appropriate.

225

Data connection open; no transfer in progress.

226

Closing data connection.Requested file action successful (for example, file transfer or file abort).

227

Entering Passive Mode (h1,h2,h3,h4,p1,p2).

230

User logged in, proceed.

250

Requested file action okay, completed.

257

"PATHNAME" created.

331

User name okay, need password.

332

Need account for login.

350

Requested file action pending further information.

421

Service not available, closing control connection. This may be a reply to any command if the service knows itmust shut down.

425

Can't open data connection.

426

Connection closed; transfer aborted.

450

Requested file action not taken. File unavailable (e.g., file busy).

451

Requested action aborted: local error in processing.

452

Requested action not taken.Insufficient storage space in system.

500

Syntax error, command unrecognized. This may include errors such as command line too long.

501

Syntax error in parameters or arguments.

502

Command not implemented.

503

Bad sequence of commands.

504

Command not implemented for that parameter.

530

Not logged in.

532

Need account for storing files.

550

Requested action not taken.File unavailable (e.g., file not found, no access).

551

Requested action aborted: page type unknown.

552

Requested file action aborted. Exceeded storage allocation (for current directory or dataset). File name not allowed.

553

Requested action not taken. File name not allowed.

554

Requested action not taken: invalid REST parameter.

555

Requested action not taken: type or stru mismatch.


Top of Page

EXAMPLES
Example 1: Regular FTP Session


% ftp nordsieck.cs.colorado.edu
Connected to nordsieck.cs.colorado.edu.
220 nordsieck FTP server (Version 5.53 Tue Aug 25 10:46:12 MDT 1992) ready.
Name (nordsieck.cs.colorado.edu:yourlogin): yourlogin
331 Password required for yourlogin.
Password:
230 User yourlogin logged in.
ftp> cd HPSC/exercises
250 CWD command successful.
ftp> ls
200 PORT command successful.
550 No files found.
ftp> put tmul.out
200 PORT command successful.
150 Opening ASCII mode data connection for tmul.out.
226 Transfer complete.
local: tmul.out remote: tmul.out
1882 bytes sent in 0.0095 seconds (1.9e+02 Kbytes/s)
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for file list.
tmul.out
226 Transfer complete.
9 bytes received in 0.0021 seconds (4.3 Kbytes/s)
ftp> mput *
mput Makefile? y
200 PORT command successful.
150 Opening ASCII mode data connection for Makefile.
226 Transfer complete.
local: Makefile remote: Makefile
1020 bytes sent in 0.0062 seconds (1.6e+02 Kbytes/s)
mput tmul.out? n
ftp> quit
221 Goodbye.
% ls
. . .
Makefile
tmul.out
. . .

An FTP session to copy files from a remote machine back to nordsieck.cs.colorado.edu
using one's own login and password.
Example 2: Anonymous FTP Session


% ftp cs.colorado.edu
Connected to cs.colorado.edu.
220 bruno FTP server (SunOS 4.1) ready.
Name (cs.colorado.edu:yourlogin): anonymous
331 Guest login ok, send ident as password.
Password:
230-This server is courtesy of Sun Microsystems, Inc.
230-
230-The data on this FTP server can be searched and accessed via WAIS, using
230-our Essence semantic indexing system. Users can pick up a copy of the
230-WAIS ".src" file for accessing this service by anonymous FTP from
230-ftp.cs.colorado.edu, in pub/cs/distribs/essence/aftp-cs-colorado-edu.src
230-This file also describes where to get the prototype source code and a
230-paper about this system.
230-
230-
230 Guest login ok, access restrictions apply.
ftp> cd /pub/HPSC
250 CWD command successful.
ftp> ls
200 PORT command successful.
150 ASCII data connection for /bin/ls (128.138.242.10,3133) (0 bytes).
ElementsofAVS.ps.Z
. . .
execsumm_tr.ps.Z
viShortRef.ps.Z
226 ASCII Transfer complete.
418 bytes received in 0.043 seconds (9.5 Kbytes/s)
ftp> get README
200 PORT command successful.
150 ASCII data connection for README (128.138.242.10,3134) (2881 bytes).
226 ASCII Transfer complete.
local: README remote: README
2939 bytes received in 0.066 seconds (43 Kbytes/s)
ftp> bye
221 Goodbye.
% ls
. . .
README
. . .

An FTP session to obtain the HPSC README file from the cs.colorado.edu anonymous ftp
directory using a loginname of anonymous and a password of one's own electronic mail
address.

Top of Page


PROTOCOL RELATIONS
Parent layer
Child layer
TCP
FTP
Data
Control
Top of Page

GLOSSARY
E-mail
The transmission of messages over communications networks. Most mainframes, minicomputers, and computer networks have an e-mail system. Most e-mail systems include a rudimentary text editor for composing messages, but many allow you to edit your messages using any editor you want. Sent messages are stored in electronic mailboxes until the recipient fetches them. All online services and Internet Service Providers (ISPs) offer e-mail, and most also support gateways so that you can exchange mail with users of other systems.

Although different e-mail systems use different formats, there are some emerging standards that are making it possible for users on all systems to exchange messages. To date, though, the de facto addressing standard is the one used by the Internet system because almost all e-mail systems have an Internet gateway.

HTTP
HTTP(HyperText Transfer Protocol) defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands. For example, when you enter a URL in your browser, this actually sends an HTTP command to the Web server directing it to fetch and transmit the requested Web page.

The other main standard that controls how the World Wide Web works is HTML, which covers how Web pages are formatted and displayed.

HTTP is called a stateless protocol because each command is executed independently, without any knowledge of the commands that came before it. This is the main reason that it is difficult to implement Web sites that react intelligently to user input. This shortcoming of HTTP is being addressed in a number of new technologies, including ActiveX, Java, JavaScript and cookies.

Internet
A global network connecting millions of computers. More than 100 countries are linked into exchanges of data, news and opinions.

Unlike online services, which are centrally controlled, the Internet is decentralized by design. Each Internet computer, called a host, is independent. Its operators can choose which Internet services to use and which local services to make available to the global Internet community. Remarkably, this anarchy by design works exceedingly well.

There are a variety of ways to access the Internet. Most online services, such as America Online, offer access to some Internet services. It is also possible to gain access through a commercial Internet Service Provider (ISP).

Logon
To make a computer system or network recognize you so that you can begin a computer session. Most personal computers have no log-on procedure -- you just turn the machine on and begin working. For larger systems and networks, however, you usually need to enter a username and password before the computer system will allow you to execute programs.

Alternative spellings for log on are log in and login.

MS-DOS
MS-DOS (Microsoft disk operating system). Originally developed by Microsoft for IBM, MS-DOS was the standard operating system for IBM-compatible personal computers.

The initial versions of DOS were very simple and resembled another operating system called CP/M. Subsequent versions have became increasingly sophisticated as they incorporated features of minicomputer operating systems. However, DOS is still a 16-bit operating system and does not support multiple users or multitasking.

For some time, it has been widely acknowledged that DOS is insufficient for modern computer applications. Microsoft Windows helped alleviate some problems, but still, it sat on top of DOS and relied on DOS for many services. Even Windows 95 sat on top of DOS. Newer operating systems, such as Windows NT and OS/2 Warp, do not rely on DOS to the same extent, although they can execute DOS-based programs. It is expected that as these operating systems gain market share, DOS will eventually disappear. In the meantime, Caldera, Inc. markets a version of DOS called DR-OpenDOS that extends MS-DOS in significant ways.

SMTP
SMTP (Simple Mail Transfer Protocol) is a protocol for sending e-mail messages between servers. Most e-mail systems that send mail over the Internet use SMTP to send messages from one server to another; the messages can then be retrieved with an e-mail client using either POP or IMAP. In addition, SMTP is generally used to send messages from a mail client to a mail server. This is why you need to specify both the POP or IMAP server and the SMTP server when you configure your e-mail application.

Server
A computer or device on a network that manages network resources. For example, a file server is a computer and storage device dedicated to storing files. Any user on the network can store files on the server. A database server is a computer system that processes database queries. Servers are often dedicated, meaning that they perform no other tasks besides their server tasks. On multiprocessing operating systems, however, a single computer can execute several programs at once. A server in this case could refer to the program that is managing resources rather than the entire computer.

TCP/IP
TCP/IP(transmission Control Protocol/Internet Protocol) is the suite of communications protocols used to connect hosts on the Internet. TCP/IP uses several protocols, the two main ones being TCP and IP. TCP/IP is built into the UNIX operating system and is used by the Internet, making it the de facto standard for transmitting data over networks. Even network operating systems that have their own protocols, such as Netware, also support TCP/IP.

User interface
User interface include the keyboard, mouse, menus of a computer system. The user interface allows the user to communicate with the operating system. Also see GUI.

Web browser
Also named browser.

Web page
Web page is a document on the World Wide Web. Every Web page is identified by a unique URL (Uniform Resource Locator).

Top of Page

REFERENCES
RFCs:
[RFC 114] A FILE TRANSFER PROTOCOL.
[RFC 281] A suggested Addition to File Transfer Protocol.
[RFC 354] THE FILE TRANSFER PROTOCOL.
                Obsoleted: RFC 264, RFC 265.
[RFC 385] COMMENTS ON THE FILE TRANSFER PROTOCOL (RFC 354).
                Updates: RFC 354.
[RFC 412] User FTP Documentation.
[RFC 414] FILE TRANSFER PROTOCOL (FTP) STATUS AND FURTHER COMMENTS.
[RFC 430] COMMENTS ON FILE TRANSFER PROTOCOL.
[RFC 438] FTP Server-Server Interaction.
[RFC 454] FILE TRANSFER PROTOCOL - Meeting Announcement and a New Proposed Document.
[RFC 458] Mail Retrieval via FTP.
[RFC 463] FTP Comments and Response to RFC 430.
[RFC 468] FTP DATA COMPRESSION.
[RFC 478] FTP Server-Server Interaction-II.
[RFC 479] Use of FTP by the NIC Journal.
[RFC 480] Host-Dependent FTP Parameters.
[RFC 506] An FTP Command-Naming Problem.
[RFC 529] A Note on Protocol Synch Sequences.
[RFC 542] File Transfer Protocol for the ARPA Network.
[RFC 593] Telnet and FTP Implementation Schedule Change.
[RFC 614] Response to RFC 607, "Comments on the File Transfer Protocol".
[RFC 624] Comments on the File Transfer Protocol.
                Obsoleted: RFC 607.
[RFC 630] FTP Error Code Usage for More Reliable Mail Service.
[RFC 640] Revised FTP Reply Codes.
[RFC 697] CWD Command of FTP.
[RFC 737] FTP Extension: XSEN.
[RFC 743] FTP extension: XRSQ/XRCP.
[RFC 775] DIRECTORY ORIENTED FTP COMMANDS.
[RFC 949] FTP UNIQUE-NAMED STORE COMMAND.
[RFC 959] File Transfer Protocol (FTP).
                Obsoleted: RFC 765.
[RFC 1123] Requirements for Internet Hosts -- Application and Support.
[RFC 1415] FTP-FTAM Gateway Specification.
[RFC 1579] Firewall-Friendly FTP.
[RFC 1635] How to Use Anonymous FTP.
[RFC 1639] FTP Operation Over Big Address Records (FOOBAR).
                Obsoleted: RFC 1545.
[RFC 2228] FTP Security Extensions. Defines FTP commands AUTH, ADAT, PROT, PBSZ, CCC, MIC, CONF, ENC .
[RFC 2389] Feature negotiation mechanism for the File Transfer Protocol. Defines FTP commands FEAT and OPTS.
[RFC 2428] FTP Extensions for IPv6 and NATs. Defines FTP commands EPRT and EPSV.
[RFC 2577] FTP Security Considerations.
[RFC 2585] Internet X.509 Public Key Infrastructure Operational Protocols: FTP and HTTP.
[RFC 2640] Internationalization of the File Transfer Protocol. Defines FTP command LANG.
[RFC 2773] Encryption using KEA and SKIPJACK.
                Updates: RFC 959.
[RFC 3027] Protocol Complications with the IP Network Address Translator.
Obsolete RFCs:
[RFC 172] THE FILE TRANSFER PROTOCOL.
                Obsoleted by: RFC 265.
                Updates: RFC 114.
[RFC 264] THE DATA TRANSFER PROTOCOL.
                Obsoleted by: RFC 354.
                Updates: RFC 171.
[RFC 265] THE FILE TRANSFER PROTOCOL.
                Obsoleted by: RFC 354.
                Updated by: RFC 294.
                Obsoleted: RFC 172.
[RFC 607] Comments on the File Transfer Protocol.
[RFC 765] FILE TRANSFER PROTOCOL.
[RFC 1545] FTP Operation Over Big Address Records (FOOBAR).
                


Top of Page

OTHER PROTOCOLS OF TCP/IP SUITE
AARP   RRP   RTP Video   RTP Audio   RTP   COPS   Gopher   HSRP   ICP   MPLS   IEEE 802.2   CIP   FTP - Data   FTP - Ctrl   IMAPS   IP Fragment   LDAPS   PUP   MSSQL   RSH   SQL   POP3s   RTELNET   RSVP   STP   VLAN   MSN   H.323   MSRDP   HTTPS   WINS   LPD   GTP   ICMPv6   POP   TELNET   H.225   VRRP   PIM   RARP   SAP   OSPF   RLOGIN   SCTP   SIP   RTCP   PPPoE   Mobile IP   IMAP3   WhoIs   SLP   NCP   PPTP   MGCP   LDAP   L2TP   Kerberos   IPv6   GRE   Ethernet SNAP   AFP   CIFS   IEEE 802.3   Finger   NBDGM   NetBEUI   NBSSN   ESP   EIGRP   EGP   DHCP   CGMP   CDP   BOOTP   AH   NBNS   EthernetII   ICQ   PPP   ARP   RIP   IPX   IGRP   IGMP   SSH   RPC   NetBIOS   TFTP   SNMP   SNA   SMB   RADIUS   NTP   NNTP   UDP   TCP   BGP   DNS   SOCKS   IMAP   RTSP   NFS   ICMP   IP   FTP   Telnet   POP3   SMTP   HTTP  
Search RFCs:

Advanced Search
Search Glossary:
Exact search
Fuzzy search


All Protocols
Submit a Request

Recommend an Article

 Layer 7 Application Layer
  AFP
  BOOTP
  CIFS
  CIP
  COPS
  DHCP
  DNS
  Finger
  FTP
  FTP - Ctrl
  FTP - Data
  Gopher
  HSRP
  HTTP
  HTTPS
  ICP
  ICQ
  IMAP
  IMAP3
  IMAPS
  Kerberos
  LPD
  MGCP
  MSN
  MSRDP
  MSSQL
  NCP
  NFS
  NNTP
  NTP
  POP
  POP3
  POP3s
  RADIUS
  RLOGIN
  RRP
  RSH
  RTCP
  RTELNET
  RTP
  RTP Audio
  RTP Video
  RTSP
  SAP
  SIP
  SLP
  SMB
  SMTP
  SNA
  SNMP
  SOCKS
  SSH
  Telnet
  TELNET
  TFTP
  WhoIs
  WINS
 Layer 6 Presentation Layer
  NBNS
  NBSSN
  NCP
  NetBIOS
 Layer 5 Session Layer
  LDAP
  LDAPS
  NCP
  NetBEUI
  RPC
 Layer 4 Transport Layer
  H.225
  H.323
  NBDGM
  NetBEUI
  PUP
  SCTP
  TCP
  UDP
 Layer 3 Network Layer
  AARP
  AH
  BGP
  EGP
  EIGRP
  ESP
  GRE
  GTP
  ICMP
  ICMPv6
  IGMP
  IGRP
  IP
  IP Fragment
  IPv6
  IPX
  Mobile IP
  MPLS
  OSPF
  PIM
  PPPoE
  RIP
  RSVP
  STP
  VRRP
 Layer 2 Data Link Layer
  ARP
  CDP
  CGMP
  Ethernet SNAP
  EthernetII
  IEEE 802.2
  IEEE 802.3
  L2TP
  PPP
  PPTP
  RARP
  SQL
  VLAN
 Layer 1 Physical Layer
© 2006 - 2007 Colasoft Co., Ltd. All rights reserved.