How do I use FTP at the command line? How do I upload file in binary or asci mode?

How do I use FTP at the command line?

First, use the command:


ftp your_hostname.com or ip_address

to make a connection to the server. Enter your account username and password when prompted.

At this point, you are logged in to the system and can use such commands as cd :


ftp> cd public_html
250 CWD command successful.
ftp>
...and put to upload a file:


ftp> put index.html
200 PORT command successful.
150 Opening ASCII mode data connection for index.html.
226 Transfer complete.
ftp>
...and get :


ftp> get index.html
local: index.html remote: index.html
200 PORT command successful.
150 Opening ASCII mode data connection for index.html (834 bytes).
226 Transfer complete.
ftp>
Other important and useful commands include:


binary This indicates that the files being transferred are binary. This must be used to transfer image files such as GIFs and

JPEGs. It should not be used for regular HTML files, however, although in most cases it will not matter. It especially

matters, however, for imagemap control files and CGI scripts.

ascii This indicates that the files being transferred are text. This should be used to transfer regular HTML files and other

files that are readable as normal text. The reason for the text-vs-binary distinction is that text files are stored in a

slightly different format on many systems, including PCs, Macs, and Unix. When the ascii mode is enabled, the files will be

translated as needed during the transfer. Failure to properly select ASCII or Binary is the most common cause of broken

images and inoperative imagemaps and CGI scripts.

delete filename This is used to delete a file.

quote site chmod permission filename This complicated command is used to change the permissions on a file. The permission can

only be specified as an octal number - for more information login by Telnet or SSH and use the command "man chmod".

My FTP client 'autodetects' ASCII and BINARY files. Should I use that?

The "autodetect" feature of most graphical FTP clients works by learning what file extensions (.html, for example) indicate

text files, and which indicate binary files. Unless you've entered all extensions you use, this method is imperfect. In

particular, if you plan on using autodetect make sure that .pl and .cgi files are recognized as text files. Text files that

are uploaded in BINARY format, particularly cgi scripts and mail configuration files, may exhibit strange behavior or simply

not work at all.


I uploaded a text file as BINARY and now it doesn't work right!

If possible, your best bet is to simply upload the file again in ASCII format, overwriting the previous copy.

I'm getting 'Blocking Call Cancelled' or some other error!

Generally speaking, FTP errors are reported in vague terms. "Blocking Call Cancelled," for instance, is a message report by

Windows 9X/NT clients that can mean most anything, although it often indicates the presence of a firewall on the client side.

As a first attempt at a solution, try changing your FTP client into "Passive" mode. The command-line command is PASV. Check

the help files for more information on graphical clients.

  • 0 Користувачі, які знайшли це корисним
Ця відповідь Вам допомогла?

Схожі статті

I get connection timed out connecting to your ftp server

This is because your firewall or ftp client needs  to be adjusted to work correctly with...

Where Can I Obtain an FTP Client?

There are a few popular places to get a FTP program. Below are a few of the sites that Revion.com...