User Tools

Site Tools


Move Text Files Between Linux and Windows

by B.H.


While all modern operating systems found on personal and business computers can, and in some cases must work with text files these files are not all created equally. Besides .txt files plain text is also used in files with extensions such as .ini, .conf, .cfg and .log among others. These files are convenient because they are relatively small compared to files such as .doc, .odf or .rtf that use many extra characters to control how the file's information looks on screen or a printed page. This also means that relatively simple software can be used to write and display files written in plain text or turn it in to the 0s and 1s that is what computers actually understand. The problems can occur however when you go to move files written on or for an operating system to another.

How Text Files Differ:

Linux, Windows and Mac-OS There are two characters used to tell the computer that the end of a line has been reached, cr, (carriage return), and lf, (line feed). DOS, and now Windows use both of these, first cr, and then lf to terminate lines, while in Linux and other Unix based OS's the lf character alone ends lines. Lf is also used by OX, but older Mac-OS use cr only, (just to keep life interesting?). When you go to use a file created on one OS on another results vary depending on the program that is trying to use them. Some editors are smart and can detect and deal with more than one line ending, some say line break, method. Some Linux editors will show the cr characters in files written in dos/windows style while the Windows notepad program will not show any line breaks in files written Unix style. Other programs will not open or be able to use with line endings formatted for another OS, period end of story, except for maybe an error message.


There are editors that let you choose how you wish to save the files they create or open. One of these is the Nano editor that comes on Vinux and is available for almost all Linux distros. Editors may preserve non-native formats, but others may automatically convert line-endings to the style native to the OS they are running on.

There are also utility programs available that convert one style of line-ending to another. My favorite is called tofrodos. I like it not because I'm sure it's better than other similar software offerings, but because it's command/syntax is so easy to remember. For basic use you just type fromdos filename or todos filename. Let's say you write a file using the Windows notepad program called file_conversion.txt and you copy it in to your home directory. Open a gnome-terminal or log-in to a console and as you will already be in your home directory just type fromdos file_conversion.txt and todos prepares a file made for Unix/Linux for use on DOS or Windows machines. The manpage for tofrodos is easy to understand even for a Linux novice, and will explain the options available beyond simple conversion.


Plain text is the most efficient human readable file format, and these files can be used across all the popular personal computing operating systems. There are however differences between OSs in how these files are read and written, so, while some programs can detect text file line-break formats that are not native to their operating system it's always best practice and often essential to create and edit text files on the operating system they will be used on, or if this is not convenient use a conversion utility such as tofrodos to "fix" them to be compatible with the destination OS.

*Tip: If a program is not opening a text file that was written on an unknown machine, make sure the file uses the proper line breaks. If in doubt run a conversion utility such as tofrodos on it and try opening it again.

move_txtfiles_linux_windows.txt · Last modified: 2017/11/11 22:47 (external edit)