When creating a new text file, should I add a .txt extension to its name?
Solution 1:
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.
Solution 2:
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.
Solution 3:
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).
Solution 4:
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 :)
Solution 5:
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.