Mime type is set for md extension in the following file:

$ cat /etc/mime.types | grep markdown
text/markdown                                   md markdown

But, on checking the Mime type of .md file it still shows as text/plain.

$ file --mime-type -b Mime.md

How can I make sure that all existing and newly generated .md files have text/markdown as the MIME type? Also, will the changed Mime type would persist if I email the file to a friend (who also happens to use the same filesystem as me - ext4 )?

Also the contents of /usr/share/mime/text/markdown.xml is:

<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="text/markdown">
  <!--Created automatically by update-mime-database. DO NOT EDIT!-->
  <comment>Markdown document</comment>
  <comment xml:lang="ast">Documentu Markdown</comment>
  <comment xml:lang="bg">Документ — Markdown</comment>
  <comment xml:lang="ca">document Markdown</comment>
  <comment xml:lang="cs">dokument Markdown</comment>
  <comment xml:lang="da">Markdown-dokument</comment>
  <comment xml:lang="de">Markdown-Dokument</comment>
  <comment xml:lang="el">Έγγραφο Markdown</comment>
  <comment xml:lang="en_GB">Markdown document</comment>
  <comment xml:lang="es">documento Markdown</comment>
  <comment xml:lang="eu">Markdown dokumentua</comment>
  <comment xml:lang="fi">Markdown-asiakirja</comment>
  <comment xml:lang="fr">document Markdown</comment>
  <comment xml:lang="ga">cáipéis Markdown</comment>
  <comment xml:lang="gl">documento de Markdown</comment>
  <comment xml:lang="he">מסמך Markdown</comment>
  <comment xml:lang="hr">Markdown dokument</comment>
  <comment xml:lang="hu">Markdown dokumentum</comment>
  <comment xml:lang="ia">Documento Markdown</comment>
  <comment xml:lang="id">Dokumen markdown</comment>
  <comment xml:lang="it">Documento Markdown</comment>
  <comment xml:lang="ja">Markdown </comment>
  <comment xml:lang="kk">Markdown құжаты</comment>
  <comment xml:lang="ko">마크다운 문서</comment>
  <comment xml:lang="lv">Markdown dokuments</comment>
  <comment xml:lang="nl">Markdown document</comment>
  <comment xml:lang="oc">document Markdown</comment>
  <comment xml:lang="pl">Dokument Markdown</comment>
  <comment xml:lang="pt">documento Markdown</comment>
  <comment xml:lang="pt_BR">Documento Markdown</comment>
  <comment xml:lang="ru">Документ Markdown</comment>
  <comment xml:lang="sk">Dokument Markdown</comment>
  <comment xml:lang="sl">Dokument Markdown</comment>
  <comment xml:lang="sr">Маркдаун документ</comment>
  <comment xml:lang="sv">Markdown-dokument</comment>
  <comment xml:lang="tr">Markdown belgesi</comment>
  <comment xml:lang="uk">документ Markdown</comment>
  <comment xml:lang="zh_CN">Markdown 文档</comment>
  <comment xml:lang="zh_TW">Markdown 文件</comment>
  <sub-class-of type="text/plain"/>
  <glob pattern="*.md"/>
  <glob pattern="*.mkd"/>
  <glob pattern="*.markdown"/>
  <alias type="text/x-markdown"/>
  • 1
    Use mimetype to determine the file type instead of file, which is hinted by this earlier post: file command apparently returning wrong MIME type. Perhaps OP actually wanted to ask "how to ensure the text file will be read as Markdown file by an external user?"
    – user125388
    Commented Jun 26, 2019 at 8:14
  • @clearkimura $ mimetype -a Mime.md Mime.md: text/markdown Mime.md: text/plain. Can a file have multiple Mime (as shown in the above example)?
    – Porcupine
    Commented Jun 26, 2019 at 13:15
  • 1
    According to the manpage, -a option will "show output of all rules that match the file". You can include the debug option; run mimetype -D -a filename.md to see why it does so. Not sure if anyone would understand what you are trying to solve here; you should edit your question to clarify.
    – user125388
    Commented Jun 26, 2019 at 15:08


You must log in to answer this question.

Browse other questions tagged .