Copyright Phillip Farrell. Last revision May 10, 2007

Ftp is the original Internet standard file transfer program. It sends your password over the network in plain text format. Use the ssh family of programs instead to encrypt your password and data when transferring files. The ftp protocol is really only appropriate now for file distribution via anonymous ftp.

This web page describes basic usage instructions for the ftp program that is built-in to all Unix and Linux systems and accessed from a shell command-line window.

PCs running the Windows or Mac OS X operating systems also have a built-in command line ftp program that can be used the same way as the Unix version described here. On Windows, open a Command Prompt window by selecting the Run command from the Start menu, and then typing cmd.exe and pressing the RETURN key. On Mac OS X, open the Terminal application in the Utilities subfolder of the Applications folder. Then follow the instructions below. There are also many ftp programs available for Windows and Mac OS X that use a graphical interface.

Start an ftp file transfer session to a remote computer by typing the command

ftp hostname

You substitute the IP hostname or address of the remote computer for hostname.

You will be prompted to enter a user account and password on the remote system. Some machines that serve as "public archives" have an account named anonymous that requires no password - you type in your email address (for identification only) in response to the password prompt.

Once connected to the remote system, you give commands to the ftp program to manipulate the files on the remote system or copy files between the two systems. You specify directory and file names in the syntax specific to each system. For example, if using ftp to go from a Unix to a VMS system, your local (Unix) directories and filenames are specified in the normal Unix style, for example, /home/ges/joe/file, but your remote (VMS) directories and filenames are specified in the VMS style, for example, disk1:[dir.sub]file.type;1

Your file manipulations are limited by the normal file permissions of your account on each system. For anonymous ftp, you are normally allowed only read access to the remote site, and only to specific directories (usually, the pub or public directory trees).

The actual ftp commands are the same regardless of type of system. Most commonly used commands:

  • lcd localdir
    Change the working directory (read from or write to) on the local machine to localdir.
  • cd remotedir
    Change the working directory on the remote machine to remotedir.
  • dir
    Get a complete listing of the contents of the remote working directory (like ls -l). You can also specify a directory, filenames, or wildcards (for example, *.c) as an argument to dir to see a listing of only the files that match. This works the same as the Unix ls command.
  • binary
    Change transfer mode to binary. In this mode, each bit is preserved exactly as found. All binary data, graphics and photos, compiled programs, compressed files, or archive files (like tar, Stuffit, or Zip) must be transferred in binary mode. BinHex files for Macintosh have already been encoded into ASCII, so they should not be transferred in binary mode.
  • ascii
    Change transfer mode to ASCII for text files. In this mode, ftp may do some automatic substitutions to account for differences in text character encoding and line terminator conventions between systems. This is the default mode. Some Unix ftp programs can tell when the remote system is also Unix and set the default mode to "binary" in that case. Use ASCII mode to transfer files that are truly text only. Word processor documents from Windows PCs or Macintoshes are not text only, because they contain numerous control characters that represent the formatting commands. Transfer them in binary mode.
  • get remotename localname
    Copy the file remotename from the remote system and put the copy at localname on the local system. These names can be just filenames in the current working directories, or relative or absolute pathnames including directories. localname is optional; if not given, the remotename is used for the local copy (there may be truncation if the local system cannot handle names as long as the remote, as for example from Unix to PC-DOS). This command overwrites any existing local file of the same name.
  • put localname remotename
    Copy the file localname from the local system and put the copy at remotename on the remote system. put works just like get, only in the reverse direction. This command overwrites any existing remote file of the same name. Obviously, it only works if you have write permission in the remote directory.
  • ! command
    This command is usually available only on Unix implementations. Temporarily suspend the ftp program and execute command on the local system. When command is done, return to the ftp prompt. This is most useful to do a listing of the local machine directory, for example, ! ls
  • bye or quit
    Close the network connection and exit the ftp program.

Other commands within ftp give you more control of the method of transfer, let you delete or rename files on the remote system, or even connect to two remote systems and do a third party transfer between them. Check man ftp on pangea for more information.

Comments or Questions?