Linux:桌面系统中的文件后缀和类型

发布时间:2026/10/27 18:19:20

Linux:桌面系统中的文件后缀和类型 相关阅读Linuxhttps://blog.csdn.net/weixin_45791458/category_12234591.html?spm1001.2014.3001.5482Linux中的文件后缀与Windows系统有些不同因为其似乎没有很重要一个文件是否可执行对后缀没有要求。但是后缀依然可以用于表示文件类型也可以据此选择不同类型文件的默认打开方式。在Linux系统中MIME多用途互联网邮件扩展文件类型机制是用来识别和处理不同类型文件的一种方式。MIME类型也称为互联网媒体类型最初是为了在电子邮件系统中识别不同格式的文件而设计的但后来被广泛应用于HTTP传输中以及在操作系统如Linux中识别文件格式。MIME类型通常由两部分组成类型(type)和子类型(subtype)用斜线分隔。例如test/html表示HTML文档image/jpeg表示JPEG图像文件。/usr/share/mime目录中有一些XML文件它们是自动生成的在安装或更新shared-mime-info包时由update-mime-database命令更新它们规定了MIME类型、以及文件后缀和文件类型的映射关系。/usr/share/mime目录下的types文件中包括了目前的所有MIME类型如下所示。*********************** text/xmcd video/3gpp video/3gpp2 video/annodex video/dv video/isivideo video/mp2t video/mp4 video/mpeg video/ogg video/quicktime video/vnd.mpegurl video/vnd.rn-realvideo video/vnd.vivo video/wavelet video/webm video/x-anim video/x-flic ***********************下面用/usr/share/mime/text目录下x-python.xml文件进行举例说明。?xml version1.0 encodingutf-8? mime-type xmlnshttp://www.freedesktop.org/standards/shared-mime-info typetext/x-python !--Created automatically by update-mime-database. DO NOT EDIT!-- commentPython script/comment comment xml:langarسكربت بايثون/comment comment xml:langbelatinSkrypt Python/comment comment xml:langbgСкрипт — Python/comment comment xml:langcascript Python/comment comment xml:langcsskript Python/comment comment xml:langdaPythonprogram/comment comment xml:langdePython-Skript/comment comment xml:langelΔέσμη ενεργειών Python/comment comment xml:langen_GBPython script/comment comment xml:langeoPython-skripto/comment comment xml:langessecuencia de órdenes en Python/comment comment xml:langeuPython script-a/comment comment xml:langfiPython-komentotiedosto/comment comment xml:langfoPython boðrøð/comment comment xml:langfrscript Python/comment comment xml:langgascript Python/comment comment xml:langglScript en Python/comment comment xml:langheתסריט Python/comment comment xml:langhrPython skripta/comment comment xml:langhuPython-parancsfájl/comment comment xml:langiaScript Python/comment comment xml:langidSkrip Python/comment comment xml:langitScript Python/comment comment xml:langjaPython スクリプト/comment comment xml:langkkPython сценарийі/comment comment xml:langko파이썬 스크립트/comment comment xml:langltPython scenarijus/comment comment xml:langlvPython skripts/comment comment xml:langmsSkrip Python/comment comment xml:langnbPython-skript/comment comment xml:langnlPython-script/comment comment xml:langnnPython-skript/comment comment xml:langocescript Python/comment comment xml:langplSkrypt Python/comment comment xml:langptscript Python/comment comment xml:langpt_BRScript Python/comment comment xml:langroScript Python/comment comment xml:langruсценарий Python/comment comment xml:langskSkript Python/comment comment xml:langslSkriptna datoteka Python/comment comment xml:langsqScript Python/comment comment xml:langsrПитонова скрипта/comment comment xml:langsvPythonskript/comment comment xml:langtrPython betiği/comment comment xml:langukскрипт мовою Python/comment comment xml:langviVăn lệnh Python/comment comment xml:langzh_CNPython 脚本/comment comment xml:langzh_TWPython 指令稿/comment sub-class-of typeapplication/x-executable/ sub-class-of typetext/plain/ glob pattern*.py/ glob pattern*.pyx/ glob pattern*.wsgi/ /mime-typeXML文件中类似commentPython script/comment的字段规定了在桌面系统下text/x-python类型文件在进行查询时显示的类型。最后的glob pattern*.py/字段规定了哪些后缀的文件会被识别为text/x-python类型不加说明后缀是大小写不敏感的即.py、.PY、.pY和.Py都会被识别为text/x-python类型。下面给出了一个大小写敏感的例子出现在x-csrc.xml中其中的glob pattern*.C case-sensitivetrue/字段说明了只有大写C后缀的文件才会被识别为text/x-csrc类型。?xml version1.0 encodingutf-8? mime-type xmlnshttp://www.freedesktop.org/standards/shared-mime-info typetext/x-csrc !--Created automatically by update-mime-database. DO NOT EDIT!-- commentC source code/comment comment xml:langarشفرة مصدر سي/comment comment xml:langbelatinKryničny kod C/comment comment xml:langbgИзходен код — C/comment comment xml:langcacodi font en C/comment comment xml:langcszdrojový kód C/comment comment xml:langdaC-kildekode/comment comment xml:langdeC-Quelltext/comment comment xml:langelΠηγαίος κώδικας C/comment comment xml:langen_GBC source code/comment comment xml:langeoC-fontkodo/comment comment xml:langescódigo fuente en C/comment comment xml:langeuC iturburu-kodea/comment comment xml:langfiC-lähdekoodi/comment comment xml:langfoC keldukota/comment comment xml:langfrcode source C/comment comment xml:langgacód foinseach C/comment comment xml:langglcódigo fonte de C/comment comment xml:langheקוד מקור של C‎/comment comment xml:langhrC izvorni kod/comment comment xml:langhuC-forráskód/comment comment xml:langiaCodice-fonte C/comment comment xml:langidKode program C/comment comment xml:langitCodice sorgente C/comment comment xml:langjaC ソースコード/comment comment xml:langkaC-ის საწყისი კოდი/comment comment xml:langkkC бастапқы коды/comment comment xml:langkoC 소스 코드/comment comment xml:langltC pradinis kodas/comment comment xml:langlvC pirmkods/comment comment xml:langmsKod sumber C/comment comment xml:langnbC-kildekode/comment comment xml:langnlC-broncode/comment comment xml:langnnC-kjeldekode/comment comment xml:langoccòde font C/comment comment xml:langplKod źródłowy C/comment comment xml:langptcódigo origem C/comment comment xml:langpt_BRCódigo-fonte C/comment comment xml:langroCod sursă C/comment comment xml:langruисходный код C/comment comment xml:langskZdrojový kód jazyka C/comment comment xml:langslDatoteka izvorne kode C/comment comment xml:langsqKod burues C/comment comment xml:langsrЦ изворни ко̂д/comment comment xml:langsvC-källkod/comment comment xml:langtrC kaynak kodu/comment comment xml:langukвихідний код мовою C/comment comment xml:langviMã nguồn C/comment comment xml:langzh_CNC 源代码/comment comment xml:langzh_TWC 源碼/comment sub-class-of typetext/x-csrc/ glob pattern*.cpp/ glob pattern*.cxx/ glob pattern*.cc/ glob pattern*.C case-sensitivetrue/ glob pattern*.c/ /mime-type下图展示了在桌面系统GNOME中一个.py后缀文件的类型查询结果。可以看出首先根据系统语言这里是默认显示了comment字段规定的类型名并且在小括号中显示了MIME类型。不同的桌面系统的显示结果可能有差异下面是桌面系统XFCE中一个.py后缀文件的类型查询结果。其中根据系统语言这里是zh_CN显示了comment字段规定的类型名即Python 脚本。需要注意的是一个有后缀的文件显示出来的类型是由后缀决定的这可能与文件真实类型不符合。如一个可执行二进制文件如果重命名以.py为后缀则其显示出来的类型会是错误的Python 脚本。所以一个文件的后缀只是对其类型的一个暗示但并不确保其准确性。如果要准确识别一个文件的类型可以使用file命令它是通过文件的魔术头识别文件类型的因此更为准确如下所示。$ file test.py test.py: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]8c8cfe14852611f912f695c4ff7fae0b6607382d, not stripped对于没有后缀的文件桌面系统会根据文件内容尝试推断其类型即如果他是一个二进制文件则可能推断为executable (application/x-executable)类型。下面是一个例子展示了一个没有后缀的jupyterjson格式的文件被正确识别为了Jupyter Notebook (application/x-ipynbjson)类型。{ cells: [ { cell_type: markdown, metadata: {}, source: [ # 简单的Jupyter Notebook ] }, { cell_type: code, execution_count: 1, metadata: {}, outputs: [], source: [ print(Hello, world!) ] } ], metadata: { kernelspec: { display_name: Python 3, name: python3 } }, nbformat: 4, nbformat_minor: 2 }
延伸阅读

更多相关文章

2026/10/27 18:14:19

深度学习语义分割技术演进与实战解析

1. 语义分割技术发展概述语义分割作为计算机视觉领域的核心任务之一,在过去十年间经历了从传统方法到深度学习范式的革命性转变。这项技术能够为图像中的每个像素分配语义类别标签,在自动驾驶、医疗影像分析、遥感解译等场景中发挥着关键作用。2015年FCN…

2026/10/27 18:14:19

电机失速与堵转的本质区别及六大核心原因排查指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/27 18:14:19

从RAW到RGB:ISP流水线拆解与AI-ISP工程实战

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/27 18:59:28

写一个扫雷代码

第一步先将菜单以及选项给呈现出来使用do....while来实现选项&#xff0c;因为只需要执行此选项即可&#xff0c;因此设置返回值为void#include<stdio.h> static void menu() {printf("****************\n");printf("***1.开始游戏***\n");printf(&q…

2026/10/27 18:59:28

从零到落地:基于 LangChain 的大模型应用开发全流程实战

从零到落地&#xff1a;基于 LangChain 的大模型应用开发全流程实战 很多人学习大模型开发时都会陷入一个误区&#xff1a;以为调用模型接口就是在做 AI 应用。实际接触过生产项目的人都知道&#xff0c;单纯调用 API 只能做出一个能对话的壳子&#xff0c;真正有价值的应用——…

2026/10/27 18:59:28

多智能体协作系统设计:编排模式、通信协议与工程落地

多智能体协作系统设计&#xff1a;编排模式、通信协议与工程落地 单个大模型智能体能力再强&#xff0c;也存在天然的边界&#xff1a;上下文窗口有限、无法同时胜任多个专业领域、单个智能体的决策链一旦出错就容易整体失败。多智能体协作系统的出现&#xff0c;正是为了用&qu…

2026/10/27 18:59:28

高职院校智慧体适能实训室建设

随着健康中国战略落地以及职业教育提质培优工作推进&#xff0c;运动健康指导、健身指导与管理、社会体育等专业&#xff0c;对理实一体化实训条件提出更高要求。传统体适能实训大多依靠常规健身器械&#xff0c;教学评价高度依赖授课教师经验判断&#xff0c;体测数据分散存储…

2026/10/27 18:59:28

开源项目stdlayout:每个项目从第一天起,就有同一套目录和 .gitignore

新建仓库的前十分钟,最容易埋雷 新开一个项目,前十分钟干的事,你闭着眼都能背出来。 建 src,建 tests,从上一个项目里翻出 .gitignore 复制过来,心想"差不多够用了",然后开始写代码。 雷就是在这十分钟里埋下的。 雷一:.gitignore 是抄来的 抄来的 .gitignore 是…

2026/10/27 18:54:28

ROM搜索算法对多个DS18B20进行地址读取

ROM搜索算法对多个DS18B20进行地址读取 ROM搜索算法是一个用于解决1-wire总线上多个器件地址寻址的算法&#xff1b;实际应用&#xff0c;假设在一条总线上挂载了多个 1-Wire器件、但主机不知道它们地址无法进行通信&#xff1b;此时可以通过ROM搜索算法枚举出每一个器件的64位…

2026/10/27 14:24:03

全国计算机二级C语言真题PDF高效刷题指南

简介&#xff1a;这份PDF是全国计算机二级C语言考试的试题与答案解析&#xff0c;专为备考二级C语言的考生准备。内容涵盖C语言特点与设计理念、程序基本组成单位、main函数执行流程、函数嵌套调用规则、标识符命名规范、整型实型字符型数据类型、八进制十六进制数合法形式、运…

2026/10/27 9:34:54

requests+BeautifulSoup:爬虫抓取h1标题的入门实战指南

简介&#xff1a;一份以实战为导向的Python爬虫入门资源&#xff0c;面向具备基本编程基础、希望快速掌握网络数据抓取的初学者&#xff0c;可解决从零编写简单爬虫的常见困惑。实例以requests库发送HTTP请求、BeautifulSoup解析HTML文档&#xff0c;完整演示从网页中提取 标题…

2026/10/27 0:59:21

递推最小二乘参数辨识MATLAB编程:二阶系统与渐消记忆实现

简介&#xff1a;这是一篇面向控制系统、信号处理与机器学习等领域学习者的最小二乘参数辨识程序说明文档。资源共包含一个docx格式文档&#xff0c;压缩包大小七十八KB&#xff0c;内容围绕递推最小二乘算法和渐消记忆最小二乘算法展开&#xff1a;先构造一个极点位于单位圆内…

2026/10/27 0:02:28

WorkBuddy_新建任务与工作模式19_“模式选错”的典型代价

“模式选错”的典型代价 摘要 在软件工程中&#xff0c;设计模式、架构模式、并发模式乃至团队协作模式的选择&#xff0c;往往在项目早期就决定了后续的开发效率和维护成本。本文通过多个真实场景&#xff0c;剖析“模式选错”带来的典型代价——包括返工成本、技术债务累积、…

2026/10/27 0:02:28

WorkBuddy_新建任务与工作模式20_新手推荐路径

新手推荐路径 摘要 在 AI 辅助开发工具快速普及的今天&#xff0c;新手面对最多的困惑往往不是"工具够不够强"&#xff0c;而是"我该从哪一步开始用"。本文提出一条经过实践验证的三阶段学习路径&#xff1a;先从 Ask&#xff08;问答式交互&#xff09;起…

还想了解更多?直接咨询顾问

免费诊断 + 免费方案 + 透明报价。

全国咨询热线400-8866-253
免费获取方案
☎咨询二维码 ☎ ↑