Nautilus showing incorrect file type for text files with extension .s

I have a mixed language project with some Assembler files, which have file extension “.s”. When any of the source directories containing Assembler files are displayed in Files/Nautilus, the .s files are shown like this:


Other files (.c, .cpp, etc.) show as text files. Right clicking on one of the .s files shows the following:


However, the file shell command shows them as ASCII text files:

someguy@somesys:~/projects/someproj/src$ file mzzflt*.s
mzzfltc.s: ASCII text
mzzfltr.s: ASCII text

I’m quite sure that this behaviour started recently, although I’m not in a position to prove it. I have the same behaviour on two systems running Ubuntu 22.04 LTS. On one of the two systems, double-clicking one of these files still opens the file in gedit. On the other, it tries unsuccessfully to open it in archive manager.

For both systems:

someguy@somesys::~$ nautilus --version
GNOME nautilus 42.6

Checking if there is anything stupid that I’ve missed.

Nautilus uses shared-mime-info to determine the mime type of file. Maybe that package got updated recently? You can also check what the mime type of a file would be according to that using xdg-mime query filetype mzzfltc.s to make sure the issue is not on the nautilus side.


Thanks Sebastian! shared-mime-info is at 2.1.2 (14 Jan 2022), so almost 2 years old. The output of xdg-mime query filetype mzzfltc.s is consistent with what Nautilus properties for the file shows.

I found this in

  <mime-type type="application/x-ms-dos-executable">
    <magic priority="50">
      <match type="string" value="MZ" offset="0"/>

The first two characters of the Assembler files happen to be “MZ”.

A quick test case:

someguy@somesys:~/projects/mimetest$ echo "MZ" > MZFile.s
someguy@somesys:~/projects/mimetest$ echo "mz" > mzFile.s
someguy@somesys:~/projects/mimetest$ xdg-mime query filetype MZFile.s
someguy@somesys:~/projects/mimetest$ xdg-mime query filetype mzFile.s

So it’s a quirk of the file contents. I couldn’t find any <glob pattern="*.s"/>, so it seems that the initial “MZ” is determining the mime type. It’s clearly not Nautilus’s problem.

1 Like

You can create own MIME type that overrides the defaults:

tee /tmp/custom.xml << EOF > /dev/null
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="">
<mime-type type="application/x-assembly">
<comment>Assembly source code</comment>
<generic-icon name="text-x-generic"/>
<sub-class-of type="text/plain"/>
<glob pattern="*.s"/>
xdg-mime install --novendor /tmp/custom.xml

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.