Please Whitelist This Site?

I know everyone hates ads. But please understand that I am providing premium content for free that takes hundreds of hours of time to research and write. I don't want to go to a pay-only model like some sites, but when more and more people block ads, I end up working for free. And I have a family to support, just like you. :)

If you like The TCP/IP Guide, please consider the download version. It's priced very economically and you can read all of it in a convenient format without ads.

If you want to use this site for free, I'd be grateful if you could add the site to the whitelist for Adblock. To do so, just open the Adblock menu and select "Disable on tcpipguide.com". Or go to the Tools menu and select "Adblock Plus Preferences...". Then click "Add Filter..." at the bottom, and add this string: "@@||tcpipguide.com^$document". Then just click OK.

Thanks for your understanding!

Sincerely, Charles Kozierok
Author and Publisher, The TCP/IP Guide


NOTE: Using software to mass-download the site degrades the server and is prohibited.
If you want to read The TCP/IP Guide offline, please consider licensing it. Thank you.

The Book is Here... and Now On Sale!

Searchable, convenient, complete TCP/IP information.
The TCP/IP Guide

Custom Search







Table Of Contents  The TCP/IP Guide
 9  TCP/IP Application Layer Protocols, Services and Applications (OSI Layers 5, 6 and 7)
      9  TCP/IP Key Applications and Application Protocols
           9  TCP/IP File and Message Transfer Applications and Protocols (FTP, TFTP, Electronic Mail, USENET, HTTP/WWW, Gopher)
                9  TCP/IP General File Transfer Protocols (FTP and TFTP)
                     9  File Transfer Protocol (FTP)

Previous Topic/Section
FTP User Interface and User Commands
Previous Page
Pages in Current Topic/Section
1
Next Page
Trivial File Transfer Protocol (TFTP)
Next Topic/Section

FTP Sample User and Internal Command Dialog

The previous two sections have described how FTP operates, and shown the commands and reply codes used to implement communication between an FTP user and an FTP server. Having now seen all the details of how FTP works, let's tie everything together by looking at a sample FTP session between an FTP client and server, to see FTP commands and replies “in action”.

In this example, I will invoke FTP from a client to retrieve a text file from an FTP server, then delete the file from the server and the directory that contained it. In the process, I will issue some additional commands to illustrate more of how FTP works. I will enable “debug” mode in the FTP client so that for each user command we can see the actual FTP protocol commands generated.

Table 233 shows the sample FTP dialog, slightly simplified. The first column contains commands entered by the user (that's me) on the FTP client. The second shows the actual protocol command(s) sent to the FTP server in highlighted text, and the reply returned from the server to the client in plain text. The third contains descriptive comments.


Table 233: Sample FTP Session

User Command

FTP Protocol Command / FTP Server Reply

Comments

ftp -d pcguide.com

Connected to pcguide.com.
220 ftp199.pair.com NcFTPd Server (licensed copy) ready.
Name (pcguide.com:ixl):

This is the command to start up FTP. The “-d” enables debug mode. In this initial step the TCP control connection is made, and the server replies with a 220 reply code indicating that it is ready for user identification. The FTP client automatically prompts for the user name.

ixl

USER ixl

331 User ixl okay, need password.

I use “ixl” for user names commonly. Here, the FTP client sends the user name and the server responds back asking for the password.

****

PASS XXXX

230-You are user #1 of 300 simultaneous users allowed.
230-
230-
230-Welcome to (<system name>)
230-
230 Logged in.

SYST

215 UNIX Type: L8
Remote system type is UNIX.
Using binary mode to transfer files.

I enter my password, which is sent to the FTP server, and a bunch of stuff happens. J The server authenticates me and sends back a 230 message. This tells me the login was successful. It also provides me with additional information.

The FTP client then automatically sends a SYST command to tell me what type of system the server is using, in this case UNIX. The client also tells me that binary mode has been selected by default; this is often the default when doing FTP from UNIX to UNIX (as I am doing here) since there is no need for ASCII mode when moving text files between similar systems.

pwd

PWD

257 “/usr/home/ixl” is cwd.

I check the current working directory (“cwd”), which the server tells me is my own home directory on this system.

cd ftptest

CWD ftptest

550 No such directory.

I try to go to a directory called “ftptest” but that was the wrong name, so I get a 550 error for my trouble. (I wasn't trying to do this, I forgot the directory name but figured I might as well show it to you anyway! J)

cd ftpdemo

CWD ftpdemo

250 “/usr/home/ixl/ftpdemo” is new cwd.

I got the name right this time and the server confirms the new working directory.

dir

PASV

227 Entering Passive Mode (ip1,ip2,ip3,ip4,193,224)

LIST

150 Data connection accepted from ip5.ip6.ip7.ip8:4279; transfer starting.
-rw-r—r— 1 ixl users 16 May 22 17:47 testfile.txt
226 Listing completed.

I request a list of files from the server. The FTP client automatically issues a PASV command and the server responds with a port number and IP address for it to use (I have not shown the IP here for security reasons.) The directory listing is then transferred from the server to the client.

asc

TYPE A

200 Type okay.

I set ASCII mode. Don't really need to, as I said above, but what the heck. Note that this client allowed me to abbreviate the ascii command as “asc”.

get testfile.txt

PASV

227 Entering Passive Mode (ip1,ip2,ip3,ip4,193,226)

RETR testfile.txt

150 Data connection accepted from ip5.ip6.ip7.ip8:4283; transfer starting for testfile.txt (16 bytes).

226 Transfer completed.
17 bytes received in 0.10 seconds (0.17 KB/s)

I get the file in this demo directory using a get command. The server accepts the PASV command and sends the file. It initially sends a 150 reply as the transfer starts (initial positive reply) then sends 226 when it is done.

Note that the port numbers used here are different (for both server and client) than they were for the directory listing I did earlier.

del testfile.txt

DELE testfile.txt

250 Deleted.

I delete the original file on the server.

cdup

CDUP

250 "/usr/home/ixl" is new cwd.

I go up to the parent directory.

rmdir ftpdemo

RMD ftpdemo

250 Directory removed.

I remove the directory that the file was in.

quit

QUIT

221 Goodbye.

I end the FTP session. The quit command also automatically closes the FTP client and returns me to the UNIX shell.


 


Previous Topic/Section
FTP User Interface and User Commands
Previous Page
Pages in Current Topic/Section
1
Next Page
Trivial File Transfer Protocol (TFTP)
Next Topic/Section

If you find The TCP/IP Guide useful, please consider making a small Paypal donation to help the site, using one of the buttons below. You can also donate a custom amount using the far right button (not less than $1 please, or PayPal gets most/all of your money!) In lieu of a larger donation, you may wish to consider purchasing a download license of The TCP/IP Guide. Thanks for your support!
Donate $2
Donate $5
Donate $10
Donate $20
Donate $30
Donate: $



Home - Table Of Contents - Contact Us

The TCP/IP Guide (http://www.TCPIPGuide.com)
Version 3.0 - Version Date: September 20, 2005

© Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.