
File Transfer
Protocol
File Transfer Protocol, or FTP, is the most
common application used to move files from one location to another across the Internet.
Command-line FTP can be used to perform two primary functions: transmission of a file FROM
the user's location TO a remote location (the ftp PUT command), and transmission
of a file TO the user's location FROM a remote location (the FTP GET
command).
Many users transmit files from and to a dial-up 'shell' account with an Internet service
provider (ISP), although it is possible (and less cryptic) to transmit files from and to
your desktop computer using an FTP 'client', such as CuteFTP or WSFTP (on Windows95) or
Fetch (Macintosh).
In this overview we will discuss the use of "command-line" FTP, or FTP from a
UNIX server or dial up 'shell' account. For assistance or questions regarding FTP clients
on your desktop machine, see the documentation for those applications.
We encourage our users to always type bin, to put FTP into binary mode. This will prevent
a lot of the problems with ctrl-M's that we see in many FTP uploads.
To initiate an FTP session:
At the prompt, type 'ftp' where <machine
name or IP address> is the machine name.
(i.e. ftp.company.com or company.com) or IP
Address (i.e. 123.45.67.89) of the location you wish to connect to.
Where Am I?
Once you are logged onto the remote
machine, you are ready to begin working with files that you wish to either receive or
transmit.
There are several UNIX commands that function in FTP to assist you:
ls
Lists the directories and files available to you
pwd
Prints the "working directory"; tells you where you are on the remote
machine.
cd directory
Changes the 'working' directory to <directory>
get filename
Retrieve <filename> from the remote system to the local or desktop system
put filename
Transmit <filename>
from the local or desktop system to the remote system
mget file1 file2
Retrieve multiple <filenames> from the remote system to the local or desktop system
mput file1 file2
Transmit multiple <filenames> from the local or desktop system to the remote system
GETting and PUTting
Files
You can use ls
and cd to help you locate the files you wish to receive from the
remote system, and then 'get or 'put the files you wish to receive or transmit.
Here is a sample transcript of a get and put session (the user is already logged in as
described above):
ftp>
*Use the cd command to change directories to the <ftp> directory*
ftp> cd ftp
S:250 CWD command successful.
*Use the ls command to show what files are in the ftp directory*
ftp> ls
S:227 Entering Passive Mode (204,91,98,240,8,90)
S:150 Opening ASCII mode data connection for /bin/ls.
total 1
-rw-r--r-- 1 winnie staff 21 Oct 8 12:42 test
S:226 Transfer complete.
*Use the lcd command to show what directory on the desktop or local machine the file
'test' will be retrieved into*
ftp> lcd
You may want to use lcd to get the
directory you are in otherwise it will take you to your home directory just as a plain cd
will in unix... lcd <location> will take you to another location inside your local
file structure.
Local directory now /youraccount/directory
*Use the get command to retrieve the remote file 'test' to the local or desktop system*
ftp> get test
S:227 Entering Passive Mode (204,91,98,240,8,92)
S:150 Opening BINARY mode data connection for test (21 bytes).
S:226 Transfer complete.
21 bytes received in 0.0011 seconds (18 Kbytes/s)
*Use the ! character to invoke a local ls -al|more command; this gives a
directory listing of files on the local or desktop system*
ftp* !ls -al|more
total 6
drwx------ 2 winnie staff 512 Oct 8 12:42 .
drwx--x--x 25 winnie staff 4096 Oct 8 12:54 ..
-rw-r--r-- 1 winnie staff 21 Oct 8 12:42 test
*Use the pwd command to indicate what directory on the remote machine the local file will
be transmitted to*
ftp> pwd
S:257 "/company.com/ftp# is current directory.
*Use the 'put' command to transmit the local file 'test' to the remote machine*
ftp> put test
S:227 Entering Passive Mode (204,91,98,240,8,105)
S:150 Opening BINARY mode data connection for test.
S:226 Transfer complete.
ftp>
Telnet
The application commonly referred to as telnet uses the TELNET communications protocol to
connect your local machine or system to a remote machine or system and allow you to send
commands to the remote system.
Most telnet applications allow you to emulate (imitate) a terminal attached to the remote
system (usually VT100 terminals, which were a common terminal type during the development
of UNIX). The advantage of this is that to the remote system your machine seems to be
attached to it directly, and therefore possesses all the privileges and abilities of a
terminal.
To initiate a telnet session:
At the prompt, type 'telnet <machine name or IP address>' where <machine name or
IP address> is the machine name (i.e. company.com) or the IP address (i.e.
123.45.67.89) of the location you wish to connect to.
Once connected:
When you connect to the remote machine or system, you will be prompted for a login name
and password. Once you provide a valid login name and password, you will be logged in.
A sample transcript of a telnet login:
yourprompt:~ >telnet company.com
Trying 123.45.67.89...
Connected to company.com.
Escape character is '^]'.
FreeBSD (transonicnet.com) (ttyp0)
login: username
Password: password
FreeBSD 2.2.5 : Mon Apr 1 17:01:04 EST 1998
You have mail.
$
I'm Connected; Now What? Once you're connected to the remote system or machine, you can
perform server commands or simple maintenance.
Unix Commands
Following are a list of common UNIX commands and their functions.
ls | more
List all files, without permissions, 'piped' through the 'more' interpreter. The 'more'
interpreter forces output of the command before the '|' (vertical pipe) into page-by-page
display, making it MUCH easier to read.
ls -al | more
List all files with permissions, again 'piping' through the 'more' interpreter.
cd directory
Change directory to <directory>
cd ..
Change up to the 'parent' directory, or the directory directly 'above' the directory
you're in.
mv file1
file2
Change the name of 'file1' to 'file2'.
mv file
directory
Move 'file' to <directory>
For example, to move the 'foo' file to the /bletch directory, you would issue the command:
mv foo bletch
Note that the subdirectory needs to be in existence already; if the bletch
subdirectorydidn't already exist, the 'mv' command will rename 'foo' to 'bletch'.
cp file
location/file
Copy the named <file> to <location>. e.g. to make a copy of the file 'foo' in
the 'bletch' subdirectory, you would issue the command:
cp foo
bletch/foo
or you can also use
cp foo bletch/
Which would leave the original 'foo' intact and make a copy of it in the 'bletch'
subdirectory. Note that you can also rename a file when you copy it, just by changing the
destination filename. For instance, to make a copy of the file 'foo' named 'bar' in the
'bletch' subdirectory, you would issue the command:
cp foo bletch/bar
rm file
Remove or delete a file. This is a powerful command; there is no 'undelete' utility in
UNIX, so once you delete a file, it's gone.The default on WDN systems is rm -i, which
means that rm will give you a message like:
rm test
rm: remove test?
To which you would then answer 'y' or 'n' depending on whether you really want to delete
that file or just made a typographical error.
You can also use
rm -f filename
**This will force a yes answer. |