This site requires JavaScript for navigation. Please enable JavaScript for the best learning experience.
 

File Transfer Protocol (FTP) is one of the oldest applications in use on the Internet. First proposed in April of 1971, it predates TCP/IP, the a pair of protocols FTP needs in order to operate. File Transfer Protocol is designed to do exactly that, transfer files between a server and a client. There are many applications which use FTP to transfer files between computers. To use FTP, you can start up the FTP program on your machine and connect to a server. The FTP application you use to connect to the server is a client, and your client software can connect to an FTP server running on port 21 on a remote machine. FTP is included on most of today's operating systems.

How FTP works:

FTP creates both a control and a data connection in order to transfer files. The control connection is based on telnet and is used to negotiate the parameters for the data transfer. This is called an active FTP connection.

  1. The client FTP application opens a control connection to the server on destination port 21, and specifies a source port as the source to which the FTP server should respond (using TCP).
  2. The FTP server responds on port 21.
  3. The FTP server and client negotiate the data transfer parameters.
  4. The FTP server opens a second connection for data on port 20 to the original client.
  5. The client responds on the data port, completing a TCP connection.
  6. Data transfer begins.
  7. The server indicates the end of the data transfer
  8. Client closes the connection once the data is received.
  9. The data connection is closed.
  10. The FTP connection is closed.

FTP COMMANDS

You can get a list of the commands by typing '?' and presing the enter key. Here is a fairly typical list of commands copied from an FTP session originated on a Windows computer.

ftp> ?
!               delete          literal         prompt          send
?               debug           ls              put             status
append          dir             mdelete         pwd             trace
ascii           disconnect      mdir            quit            type
bell            get             mget            quote           user
binary          glob            mkdir           recv            verbose
bye             hash            mls             remotehelp
cd              help            mput            rename
close           lcd             open            rmdir

ftp> remotehelp
214- The following commands are recognized (* =>'s unimplemented).
   USER    PORT    STOR    MSAM*   RNTO    NLST    MKD     CDUP
   PASS    PASV    APPE    MRSQ*   ABOR    SITE    XMKD    XCUP
   ACCT*   TYPE    MLFL*   MRCP*   DELE    SYST    RMD     STOU
   SMNT*   STRU    MAIL*   ALLO    CWD     STAT    XRMD    SIZE
   REIN*   MODE    MSND*   REST    XCWD    HELP    PWD     MDTM
   QUIT    RETR    MSOM*   RNFR    LIST    NOOP    XPWD
214 End of help.


INTIATING FILE TRANSFERS FROM THE COMMAND LINE

  1. On the command line, enter FTP <server name>.
  2. Enter your login information if prompted.
  3. Set your transfer mode to either 'ascii' or 'binary' depending upon the type of file you are transferring.
  4. You can discover what directory you have connected to by entering the comand 'pwd'.
  5. To change directories on the remote machine, enter 'cd' and the name of the directory.
  6. To change directories locally, enter 'lcd' To put a file on the remote machine, enter PUT and the name of the file.
  7. Once the transfer completes, you cen enter 'close' and then 'quit' ('!' and 'bye' also serve the same function as quit).

Passive Mode

The passive mode behavior of an FTP server:

  1. The client opens a connection to the server on TCP port 21 (command channel)
  2. The server accepts the connection.
  3. The server initiates a connection to the client using port 20 as the source port (for the data channel)
  4. The client accepts the connection and acknowledges all data transfers on port 20.

Changing UNIX File Permissions

UNIX and Linux systems use the chmod command to set file permissions. If you are FTP'ing a file to a server, and that file needs special permissions (such as CGI scripts do) you will need to change the permissions on the file. Here's how you do it from the MS-DOS command line:


quote SITE chmod nnn filename

The quote command is part of the local FTP client. The SITE command is a command executed at the server. The chmod command is what changes the mode of the file and the three n's above represent octal numbers that determine the mode of the file.

For more information about UNIX file modes, check your UNIX tutorial.

 


Bookmark this page and SHARE:  

Search

Support InetDaemon.Com

Get Tutorials in your INBOX!

Free Training