Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I create a new document aimed at containing only plain text, I am not obliged by Ubuntu to add a .txt extension to its name. It works indeed very well: gedit opens it without problem, understanding very well that it is only text.

The only two pro arguments I have found from now on for adding an extension are 1/ interoperability with Windows systems and 2/ avoiding confusion with folders having the same name. Nevertheless those two arguments do not convince me at all. As a consequence, should I keep the reflex of adding an extension to files or not?

share|improve this question
up vote 14 down vote accepted

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.

share|improve this answer

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.

share|improve this answer
The other way of dealing with the line ending problem on Ubuntu is the tofrodos package. It includes two commands that will do the line ending conversion "fromdos" and "todos". – Jonathan Sternberg Nov 15 '10 at 7:22

In many cases filename extensions are not required on Ubuntu, but often it's still a good idea to use them. Not only for Windows/Mac compatibility, but also for your own convenience. Imagine if you would remove all file extensions (.html, .jpg, .doc, .ttf, .txt, .py, .conf, etc.); you would have to check the file type all the time, instead of knowing it when reading the file name (of course filenames like README are also obvious).

share|improve this answer

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 :)

share|improve this answer

If you use linux dosent matter.Extensions are meaningless add it if you like..But if you want to view that file in windows, extension is must else you cant view the file. while keeping a well-known extension makes for better interoperability, it may also help certain (not very well written) apps behave better.For example, a mail client might choose a more appropriate MIME type for an attachment.So decide yourself.

share|improve this answer

The extension is optional but depending on your expectations you may wish to use one anyway. For example, Image viewer will fail miserably to open an image with the wrong extension. The thumbnailer will also fail in this example. You can prove this by renaming a JPEG to .GIF or .PNG for example.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.