Ubuntu – How to create new file without any default file type

mime-type

I am creating a new file either by using

in terminal: touch newfilename.someext

or

in nautilus: File > Create New Document > Empty Document

The file takes on the type "plain text document" and gets associated with the default text-editor. How can I turn-off these 2 actions?

The .somext is a new/unknown extension and I expect the system to show it as an unknown file type.

Edited August 10 2012:
I noticed that if you have a non-printing binary character in the file, then it will show as type "Unknown".

Best Answer

Your question is all about MIME types.

MIME type is resolved not only by file extension (glob patterns), but also by file contents (magic rules).

See http://library.gnome.org/admin/system-admin-guide/stable/mimetypes-modifying.html.en#-note-id301200:

When no glob patterns or magic rules match a file, then it is resolved to the MIME type text/plain if it contains textual data or application/octet-stream for binary data. If the file is empty, then it defaults to text/plain.

So exactly as you noted, file with unknown extension is resolved to text/plain, but if it contains binary data, it is resolved to application/octet-stream, which is shown as "Unknown" (if you are curious why, search for "application/octet-stream" in /usr/share/mime/packages/freedesktop.org.xml).

If you need to register new extension and associate some application with it, you should first register new MIME type, associated with desired extension, and then associate some application with this new MIME type. The following links explain this:

If you don't need to register new extension, I don't see any reason to change the default behavior (resolve text data to text/plain). It's natural.