FTP CHEAT SHEET
Apoorva Mohta
What is FTP?
FTP, or File Transfer Protocol, is the name of the application and the protocol used for
moving files between two hosts on a TCP/IP network.
There are two machines involved in an ftp transaction, a client machine, which is
sometimes called the local host, and a server machine, which is sometimes called the
remote host.
FTP Commands
Most ftp clients are command-oriented and many of the common commands are the same
regardless of the platform or operating system. Some commands are executed without any
arguments or parameters and some have optional or required arguments.
Abbreviations used:
Variable Name Meaning
ldirname Local directory name
rdirname Remote directory name
lfilename Local file name
rfilename Remote file name
Upper versus Lower Case: Remember that UNIX file and directory names are case-sensitive.
When referring to a file or directory on a UNIX system within an ftp command, type the
name EXACTLY as it is displayed with a dir or ls command.
Wild cards: When writing out filenames, wild cards can be used to display or transfer
multiple files. A wild card is a special character (or group of characters) that
substitutes for one or more characters in a file or directory name. The most common wild
card is the asterisk (*). The * represents any series of adjacent characters in a
filename. The * is helpful when you want to list all of the files that start or end with
the same few letters. Here are some examples of how the * can be used:
Example Explanation
read* Represents all filenames that begin with the string "read", including
names like readme.doc, readmeandweep, and read.
*html* Represents all filenames containing the string "html" anywhere in the
filename, including names like html-viewer-111.hqx, index.html, and text-
to-html-131.hqx.
*txt Represents all filenames that end with the string "txt", including names
like abstract.txt and readme.txt.
Commands for Opening a Session
Command Description Example
ftp Open an ftp session with the ftp ftp.cso.uiuc.edu
fully.qualified.domain.name specified host. You will be ftp boombox.micro.umn.edu
prompted to enter a userid
(login name) and password.
ftp Start the ftp client without ftp
opening a session with a remote
host. Normally, this command
will get you to an ftp> prompt.
open Open an ftp session with the open boombox.micro.umn.edu
fully.qualified.domain.name specified host from the ftp>
prompt.
user your_loginname Tell the remote host the login user ward
name of the account you will be user anonymous
using. Normally you will be
prompted for this information
when you connect to the remote
host. If you enter your login
name incorrectly, you can use
this command to enter the
correct information.
Commands for Closing a Session
Command Description Example
quit Close the current session and quit ftp client. You will be quit
returned to the operating system prompt.
close Close the current session without quitting the ftp client. close
You will be returned to the ftp> prompt and can use the open
command to open a new session.
disconnect Disconnects from the remote computer, retaining the ftp> disconnect
prompt.
Commands for Displaying the Contents of a Directory
Command Description Example
ls Display (list) the contents of the current directory on the ls
remote host.
ls rdirname Display the contents of the specified directory on the remote ls /pub/pc
host
ls rfilenames Display the specified files/directories on the remote host. ls read*
dir Display (list) the contents of the current directory on the dir
remote host in long (verbose) format. This command shows the
permissions, size, date, owner and group names, etc. for each
file in the list.
dir rdirname Display the contents of the specified directory on the remote dir
host in long format. /pub/pc
dir rfilenames Display the specified files on the remote host in long dir read*
format. dir *.txt
Note: The Examples used are for Unix (/filename). For Windows, use \filename.
Commands for Changing Directory on the Remote or Local Host
Command Description Example
cd rdirname Change to the specified directory on the remote host. When cd /pub
changing directories on a Macintosh, surround the directory
name with quotation marks.
lcd ldirname Change to the specified directory on the local host. When lcd /pub
changing directories on a Macintosh, surround the directory
name with quotation marks.
pwd Display the name of the current directory on the remote host. pwd
Commands for Specifying Transfer Type
Command Description Example
ascii Set the file transfer mode to ASCII. Use ASCII mode for text ascii
files (.txt, .doc, .asc. etc.) postscript files (.ps),
BinHexed files (.hqx), and uuencoded files (.uue).
binary Set the file transfer mode to binary. Use binary mode for binary
most executable files (except shell scripts and batch files),
formatted data files, and compressed files. Use MacBinary
mode when moving Macintosh binary files to or from a non-
Macintosh system.
Commands for Moving Files with FTP
Command Description Example
get rfilename Move the specified file from the remote host to the get
[lfilename] local host. readme.first
readme.1st
mget rfilename(s) Move the specified files from the remote host to the mget nupop*
local host. You will be asked to confirm the transfer mget *
for each file. To turn this interactive prompting off, mget *.ZIP
enter the prompt command before executing the mget
command.
put lfilename Move the specified file from the local host to the put
[rfilename] remote host. myfile.zip
mput lfilename(s) Move the specified files from the local host to the mput *.ZIP
remote host. You will be asked to confirm the transfer mput *
for each file. To turn this interactive prompting off,
enter the prompt command before executing the mput
command.
Miscellaneous FTP Commands
Command Description Example
! [command] Execute an operating system command on the local host. ! dir
Entered by itself, ! will shell out to the operating ! edit
system. readme.txt
help Display a list of ftp commands. help
help command Display help for the specified command. help ls
help put
prompt Toggle interactive mode on/off. prompt
append lfilename Appends a local file to a file on the remote computer append
[rfilename] using the current file type setting. myfile.zip
bell Toggles a bell to ring after each file transfer bell
command is completed. By default, the bell is off.
delete rfilename Deletes a single file on a remote computer. delete
readme.zip
mdelete rfilename Deletes one or more files on a remote computer. mdelete r1.zip
[ ...] r2.zip