How to Ftp in Unix






The following pages contain basic information on how to conduct a simple FTP session from a command line. Command line FTP is used if your operating system does not support a graphical interface. This document covers the basic universal commands that should work with both the Unix command line and the DOS prompt. The following examples assume you are starting from your Channel 1 Unix shell.


Starting at the Prompt
Connecting to the Server
Signing onto the Server
Seeing what is there
Changing into a directory
Looking at the files
Setting transfer type
Getting a file
Putting a file
Disconnecting from the server
Additional Information
Suggested FTP Sites

Starting at the prompt

username@channel1.com$


Connecting to the server

To start an FTP session it is necessary to know the name of the remote machine (often called a host) that you wish to log on to. For example, hostmachine.dom. the following command begins the ftp session:

username@channel1.com$ ftp hostmachine.dom


Signing on to the server

If you have an account on the remote machine you will be prompted to enter your username and password. If the host allows anonymous login, you will enter anonymous as the username and your e-mail address as the password.

Connected to hostmachine.dom.
220 FTP server (UNIX(r) System V Release 4.0) ready.
Name (ftp.server.dom:username):
anonymous
331 Guest login ok, send ident as password.
Password:
username@channel1.com
230 Guest login ok, access restrictions apply.
ftp>


Seeing what is there

To see the contents of the current directory.
ftp> ls -l
200 PORT command successful.
150 ASCII data connection for /bin/ls (199.99.99.9,9999) (0 bytes).
total 22
drwxr-xr-x   2 4002     4002         512 Jan 10  1993 bin
-rw-r--r--   1 4002     4002         630 Feb 24  1992 README
drwxr-xr-x   6 4002     4002         512 Oct 20  1993 pub
drwxr-xr-x   2 1892     4002         512 Aug 28  1994 doc
drwxr-xr-x   8 4002     4002         512 Nov 13  1994 misc
drwxr-xr-x   2 1892     1            512 Jan 10  1993 pr
drwxr-xr-x   3 4002     4002        1024 Apr 5   1995 etc
226 ASCII Transfer complete
ftp>


Moving to another directory

To change to another directory,

ftp> cd pub
250 CWD command successful
ftp>



Seeing what is there

Again to see the contents of the directory,

ftp> ls -l
200 PORT command successful.
150 Opening ASCII mode data connection for '/bin/ls.'
total 120
drwxr-sr-x  2 root  daemon      44 Jun 17 1993 README
drwxr-sr-x  2 root  daemon    2343 Jun 09 1993 file01.tar.Z
drwxr-sr-x  2 root  daemon     754 Jun 10 1993 file02.zip
drwxr-sr-x  2 root  daemon     233 Jun 19 1993 file03.tar.Z
drwxr-sr-x  2 root  daemon    1234 Jun 30 1993 file04.zip
drwxr-sr-x  2 root  daemon    2342 Jun 23 1993 file05.hqx
226 Transfer complete.
ftp>


Setting Transfer Type

Before transferring files between machines, it is necessary to set the proper mode for transfer, ASCII or Binary. Ordinary text documents (.txt, .doc, .htm) are transferred in ASCII mode. Images, compressed files, archived files, and executable files (.gif, .jpeg, .zip, .tar, .exe) are transferred in Binary mode.

ftp> ascii
200 Type set to A
ftp>
binary
200 Type set to I.
ftp>



Downloading a file

To download the file file04.zip from the remote host to your local machine:

ftp> get file04.zip
200 PORT command successful.
150 Opening BINARY mode data connection for file 04.zip (1234 bytes)
226 Transfer complete.
1234 bytes received in 0.28 seconds (4.2 Kbytes/s)
ftp>



Uploading a File

To upload the file myfile.zip from your local machine to the remote host:

ftp> put myfile.zip
200 PORT command successful.
150 Opening BINARY mode data connection for myfile.zip
226 Transfer complete.
5343 bytes sent in 0.0017 seconds (5.4e+02 Kbytes/s)
ftp>



Disconnecting From the Host

To end the FTP session:

ftp> bye
221 Goodbye.
username@user1$



The above information is the bare minimum needed to conduct an FTP session between your local machine and a remote host. For more detailed information consult the Unix manual pages for the FTP command. This can be done by typing man ftp from the Unix command line. If you have any further questions,or comments, write us at support@channel1.com.




All Content and Design
· Copyright © 2000+ ·
· Channel 1 Communications® is a service of Cybergate, Inc. ·