I'm transferring files between servers and just started noticing that some of them are getting modified to be one long continuous line as opposed to having the returns and line-breaks they originally had. I'm assuming this has something to do with the transfer-type of my FTP Client which was originally set to "Auto," but sporting "Binary" and "ASCII" as additional options.

In short, what are the differences between the ways I transfer a file from one server to another, and will these differences be capable of modifying the file in such a way as I mentioned above?

Transfering FROM Windows TO Linux.

4 Answers 4


The "Binary" transfer mode of FTP copies files exactly, byte for byte. Simple and straightforward.

When bringing text files between different operating systems, though, this might not be what you want -- different operating systems use different codes to represent line breaks. The "ASCII" mode exists for this purpose: it automatically translates all line endings from the source system's format to the destination's.

Not sure about "Auto", but I imagine it looks that the file's extension or something similar to decide whether it's a text file, and tries to guess the appropriate mode.

Which mode you want depends on exactly what you're doing with the files... if you're just copying them to back them up, then you'll probably want to copy in binary mode so they'll be exactly the same when you later restore them to the windows server again. If they need to be usable as text files (perhaps as config files for a cross-platform program?) on both sides, you'll want to use ASCII mode to translate them.

EDIT: As far as I can tell, FTPing files from Windows to Linux should never result in line breaks disappearing... however, if you copy them in ASCII mode, and then bring them back to the Windows server in binary mode, the Linux-style line endings might not be recognized on the Windows box. (Notepad won't see them; Wordpad will; YMMV with other software.)

(Today, such a convenience -- converting line endings automatically -- might seem odd in such a basic protocol as FTP. When FTP was invented, though, sending text files was the norm, and one of the goals of the protocol was to make this as easy as possible.)


There are differences indeed, and they will be messing with your non-plain-text file transfers unless you use the binary option - generally always use if ok :)

  • Is there no way to restore them? Or do I simply need to transfer with Binary now to avoid this again in the future?
    – Sampson
    Feb 8, 2010 at 16:14
  • I'm sure you could unpick them but it might take a long time, I'd be strongly tempted to retransmit them.
    – Chopper3
    Feb 8, 2010 at 16:18

What operating system are you transferring files to/from? Linux/Unix use different line breaks then Windows. So if you generate a file on a linux computer and open it on windows it may look weird. There are utilities to correct this though in my experience if you use wordpad on windows instead of notepad you'll be fine.

  • I'm authoring these on windows in an IDE, and then moving them to the linux server. At a later date, I open them from the linux server to find the long continuous line.
    – Sampson
    Feb 8, 2010 at 16:16
  • Try running dos2unix and see if that corrects the lines
    – einstiien
    Feb 8, 2010 at 16:58

Windows and Unix have different bytes at the end of lines (Windows a 0D 0A hex, Unix just a 0A). When transferring files in Binary mode, the bytes of a file will be moved from one computer unchanged. This is required for binary formats (e.g. ZIP files, Images, etc.) but can lead to problems with text files: E.g. notepad.exe on Windows will display a text file with just unix style line breaks as one long line, a unix editor might show ^M at the end of every line when seeing Windows style.

So technically for binary formats (zip, jpg, png, and endless others) you need to set the FTP to BINARY, while for text formats (HTML, PHP, CGI, etc.) you need to set it to ASCII.

Most good FTP programs also have an auto setting, which means they will determine the mode (BINARY or ASCII) depending on well known file extensions, e.g. it will automatically switch the transfer for JPG file to BINARY and send/receive a PHP file in ASCII mode.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .