When creating a new text file, should I add a .txt extension to its name?

It's completely your own decision - don't let anyone chose for you.

If it's a 'reflex' then there's no harm in keeping your current habbits. On the other hand it does look cleaner without file extensions...

In my opinion the main case for using the extension is if you're emailing files to Windows users - whilst they could still open it in Notepad (with File->Open With) they will probably confused if you leave it off.


It doesn't matter in Linux based systems whether you use a .txt extension or not. In fact, there is no special 'file extension' as on Windows - it is just part of the name. MIME types are used to determine the type of the file.

If, however, you wish to share a file with people who are still using Windows, they will have to manually choose to open the text files with notepad unless you use a .txt extension.

There are other compatibility considerations. By default, Notepad will not show new lines correctly because it uses a different line ending to Linux and other Unix like systems. The text editor will show text files in the Windows format correctly but you may need to press backspace twice in order to remove a new line.

Using a text editor called Geany you can convert between line ending types through the Document -> Set Line Endings menu. This may also be possible in the default text editor (Gedit) but I don't know how to do it.

Personally, I would not use the .txt extension or Windows line endings for daily use but I would convert the files when I needed to share them with Windows users.


If you want to learn more about how Linux identifies filetypes and why extensions are useless for that purpose, take a look at the file command man page

man file

It's a kind of magic :)