To find a files mime type which we don't know we will use file command with --mime-type argument. We know it is showing results based on given file paths extension(such like text/x-python for *.py). The list about the relation between extension and mime type would be saved somewhere such as /etc/mime.type or in /usr/share/mime/glob. But what about files which doesn't have any extensions? How could we find mime type? Explain, please. Can we do the same thing using python?
Extensions are mostly irrelevant in Linux systems. Unlike Windows, the vast majority of Linux tools don't rely on the extension at all. For example:
Now, with a different extension:
So, forget about extensions. They're very rarely relevant and
file
doesn't use them. Have a look atman file
(please readman file
, this is only part of the information there):