how to identify file nature

Asked by KKevin901

Learn from some Linux documents that Ubuntu does not use the file extension of a file to identify the file nature.

Perception on Windows environment too deep. Just curiosity how the system (Ubuntu) and user distinguish or identify what program should be used to open a file. I took a mpeg file with the "film" file icon and .mpeg file extension. Remove the .mpeg file extension, it still can be open with Mplayer as normal. But when I append .mp3 file extension, the file icon view changed to music icon. It can be open and play with music player program such as Rythmetic.

All the reason I did that is because. I download a shoutcast file and name with .mp3 extension. Then play back on Ubuntu Mplayer without problem. But it cannot play when I load it to a portable MP3 player. After couple trials, then I realize it is actually a mpeg file instead of mp3 file.

Enjoy the new world of computer outside Windows. Looking for some advise and explanation.

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu file Edit question
Assignee:
No assignee Edit question
Solved by:
Matthew Copple
Solved:
Last query:
Last reply:
Revision history for this message
Best Matthew Copple (mcopple) said :
#1

Ubuntu (and GNOME in particular) looks at the contents of the file -- specifically, the first few bytes -- to determine what kind of file it is. On the command line, you can use the file(1) command:

$ file myfile.odt
myfile.odt: OpenDocument Text

The Nautilus file manager automatically classifies your files for you, and displays an icon for each document type (music file, text file, etc.). It uses the file's MIME type (for example, an Ogg Vorbis file has MIME type of application/ogg) to determine what the file is, then picks an application to open it. You can change what application opens a particular file by right-clicking it, selecting "Open with Other Application..." in the context menu, and then selecting another application from the list or providing a custom command.

Revision history for this message
KKevin901 (kkevin901) said :
#2

Thanks Matthew Copple, that solved my question.