{
    "mode": "man",
    "parameter": "os-release",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/os-release/5/json",
    "generated": "2026-06-12T15:57:01Z",
    "synopsis": "/etc/os-release\n/usr/lib/os-release\n/etc/initrd-release",
    "sections": {
        "NAME": {
            "content": "os-release, initrd-release - Operating system identification\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "/etc/os-release\n\n/usr/lib/os-release\n\n/etc/initrd-release\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The /etc/os-release and /usr/lib/os-release files contain operating system identification\ndata.\n\nThe basic file format of os-release is a newline-separated list of environment-like\nshell-compatible variable assignments. It is possible to source the configuration from shell\nscripts, however, beyond mere variable assignments, no shell features are supported (this\nmeans variable expansion is explicitly not supported), allowing applications to read the file\nwithout implementing a shell compatible execution engine. Variable assignment values must be\nenclosed in double or single quotes if they include spaces, semicolons or other special\ncharacters outside of A–Z, a–z, 0–9. Shell special characters (\"$\", quotes, backslash,\nbacktick) must be escaped with backslashes, following shell style. All strings should be in\nUTF-8 format, and non-printable characters should not be used. It is not supported to\nconcatenate multiple individually quoted strings. Lines beginning with \"#\" shall be ignored\nas comments. Blank lines are permitted and ignored.\n\nThe file /etc/os-release takes precedence over /usr/lib/os-release. Applications should check\nfor the former, and exclusively use its data if it exists, and only fall back to\n/usr/lib/os-release if it is missing. Applications should not read data from both files at\nthe same time.  /usr/lib/os-release is the recommended place to store OS release information\nas part of vendor trees.  /etc/os-release should be a relative symlink to\n/usr/lib/os-release, to provide compatibility with applications only looking at /etc/. A\nrelative symlink instead of an absolute symlink is necessary to avoid breaking the link in a\nchroot or initrd environment such as dracut.\n\nos-release contains data that is defined by the operating system vendor and should generally\nnot be changed by the administrator.\n\nAs this file only encodes names and identifiers it should not be localized.\n\nThe /etc/os-release and /usr/lib/os-release files might be symlinks to other files, but it is\nimportant that the file is available from earliest boot on, and hence must be located on the\nroot file system.\n\nFor a longer rationale for os-release please refer to the Announcement of /etc/os-release[1].\n",
            "subsections": [
                {
                    "name": "/etc/initrd-release",
                    "content": "In the initrd[2], /etc/initrd-release plays the same role as os-release in the main system.\nAdditionally, the presence of that file means that the system is in the initrd phase.\n/etc/os-release should be symlinked to /etc/initrd-release (or vice versa), so programs that\nonly look for /etc/os-release (as described above) work correctly. The rest of this document\nthat talks about os-release should be understood to apply to initrd-release too.\n"
                }
            ]
        },
        "OPTIONS": {
            "content": "The following OS identifications parameters may be set using os-release:\n",
            "subsections": [
                {
                    "name": "General information identifying the operating system",
                    "content": "NAME=\nA string identifying the operating system, without a version component, and suitable for\npresentation to the user. If not set, a default of \"NAME=Linux\" may be used.\n\nExamples: \"NAME=Fedora\", \"NAME=\"Debian GNU/Linux\"\".\n\nID=\nA lower-case string (no spaces or other characters outside of 0–9, a–z, \".\", \"\" and \"-\")\nidentifying the operating system, excluding any version information and suitable for\nprocessing by scripts or usage in generated filenames. If not set, a default of\n\"ID=linux\" may be used.\n\nExamples: \"ID=fedora\", \"ID=debian\".\n\nIDLIKE=\nA space-separated list of operating system identifiers in the same syntax as the ID=\nsetting. It should list identifiers of operating systems that are closely related to the\nlocal operating system in regards to packaging and programming interfaces, for example\nlisting one or more OS identifiers the local OS is a derivative from. An OS should\ngenerally only list other OS identifiers it itself is a derivative of, and not any OSes\nthat are derived from it, though symmetric relationships are possible. Build scripts and\nsimilar should check this variable if they need to identify the local operating system\nand the value of ID= is not recognized. Operating systems should be listed in order of\nhow closely the local operating system relates to the listed ones, starting with the\nclosest. This field is optional.\n\nExamples: for an operating system with \"ID=centos\", an assignment of \"IDLIKE=\"rhel\nfedora\"\" would be appropriate. For an operating system with \"ID=ubuntu\", an assignment of\n\"IDLIKE=debian\" is appropriate.\n\nPRETTYNAME=\nA pretty operating system name in a format suitable for presentation to the user. May or\nmay not contain a release code name or OS version of some kind, as suitable. If not set,\na default of \"PRETTYNAME=\"Linux\"\" may be used\n\nExample: \"PRETTYNAME=\"Fedora 17 (Beefy Miracle)\"\".\n\nCPENAME=\nA CPE name for the operating system, in URI binding syntax, following the Common Platform\nEnumeration Specification[3] as proposed by the NIST. This field is optional.\n\nExample: \"CPENAME=\"cpe:/o:fedoraproject:fedora:17\"\"\n\nVARIANT=\nA string identifying a specific variant or edition of the operating system suitable for\npresentation to the user. This field may be used to inform the user that the\nconfiguration of this system is subject to a specific divergent set of rules or default\nconfiguration settings. This field is optional and may not be implemented on all systems.\n\nExamples: \"VARIANT=\"Server Edition\"\", \"VARIANT=\"Smart Refrigerator Edition\"\".\n\nNote: this field is for display purposes only. The VARIANTID field should be used for\nmaking programmatic decisions.\n\nVARIANTID=\nA lower-case string (no spaces or other characters outside of 0–9, a–z, \".\", \"\" and\n\"-\"), identifying a specific variant or edition of the operating system. This may be\ninterpreted by other packages in order to determine a divergent default configuration.\nThis field is optional and may not be implemented on all systems.\n\nExamples: \"VARIANTID=server\", \"VARIANTID=embedded\".\n"
                },
                {
                    "name": "Information about the version of the operating system",
                    "content": "VERSION=\nA string identifying the operating system version, excluding any OS name information,\npossibly including a release code name, and suitable for presentation to the user. This\nfield is optional.\n\nExamples: \"VERSION=17\", \"VERSION=\"17 (Beefy Miracle)\"\".\n\nVERSIONID=\nA lower-case string (mostly numeric, no spaces or other characters outside of 0–9, a–z,\n\".\", \"\" and \"-\") identifying the operating system version, excluding any OS name\ninformation or release code name, and suitable for processing by scripts or usage in\ngenerated filenames. This field is optional.\n\nExamples: \"VERSIONID=17\", \"VERSIONID=11.04\".\n\nVERSIONCODENAME=\nA lower-case string (no spaces or other characters outside of 0–9, a–z, \".\", \"\" and \"-\")\nidentifying the operating system release code name, excluding any OS name information or\nrelease version, and suitable for processing by scripts or usage in generated filenames.\nThis field is optional and may not be implemented on all systems.\n\nExamples: \"VERSIONCODENAME=buster\", \"VERSIONCODENAME=xenial\".\n\nBUILDID=\nA string uniquely identifying the system image originally used as the installation base.\nIn most cases, VERSIONID or IMAGEID+IMAGEVERSION are updated when the entire system\nimage is replaced during an update.  BUILDID may be used in distributions where the\noriginal installation image version is important: VERSIONID would change during\nincremental system updates, but BUILDID would not. This field is optional.\n\nExamples: \"BUILDID=\"2013-03-20.3\"\", \"BUILDID=201303203\".\n\nIMAGEID=\nA lower-case string (no spaces or other characters outside of 0–9, a–z, \".\", \"\" and\n\"-\"), identifying a specific image of the operating system. This is supposed to be used\nfor environments where OS images are prepared, built, shipped and updated as\ncomprehensive, consistent OS images. This field is optional and may not be implemented on\nall systems, in particularly not on those that are not managed via images but put\ntogether and updated from individual packages and on the local system.\n\nExamples: \"IMAGEID=vendorx-cashier-system\", \"IMAGEID=netbook-image\".\n\nIMAGEVERSION=\nA lower-case string (mostly numeric, no spaces or other characters outside of 0–9, a–z,\n\".\", \"\" and \"-\") identifying the OS image version. This is supposed to be used together\nwith IMAGEID described above, to discern different versions of the same image.\n\nExamples: \"IMAGEVERSION=33\", \"IMAGEVERSION=47.1rc1\".\n\nTo summarize: if the image updates are built and shipped as comprehensive units,\nIMAGEID+IMAGEVERSION is the best fit. Otherwise, if updates eventually completely replace\npreviously installed contents, as in a typical binary distribution, VERSIONID should be used\nto identify major releases of the operating system.  BUILDID may be used instead or in\naddition to VERSIONID when the original system image version is important.\n"
                },
                {
                    "name": "Presentation information and links",
                    "content": "HOMEURL=, DOCUMENTATIONURL=, SUPPORTURL=, BUGREPORTURL=, PRIVACYPOLICYURL=\nLinks to resources on the Internet related to the operating system.  HOMEURL= should\nrefer to the homepage of the operating system, or alternatively some homepage of the\nspecific version of the operating system.  DOCUMENTATIONURL= should refer to the main\ndocumentation page for this operating system.  SUPPORTURL= should refer to the main\nsupport page for the operating system, if there is any. This is primarily intended for\noperating systems which vendors provide support for.  BUGREPORTURL= should refer to the\nmain bug reporting page for the operating system, if there is any. This is primarily\nintended for operating systems that rely on community QA.  PRIVACYPOLICYURL= should\nrefer to the main privacy policy page for the operating system, if there is any. These\nsettings are optional, and providing only some of these settings is common. These URLs\nare intended to be exposed in \"About this system\" UIs behind links with captions such as\n\"About this Operating System\", \"Obtain Support\", \"Report a Bug\", or \"Privacy Policy\". The\nvalues should be in RFC3986 format[4], and should be \"http:\" or \"https:\" URLs, and\npossibly \"mailto:\" or \"tel:\". Only one URL shall be listed in each setting. If multiple\nresources need to be referenced, it is recommended to provide an online landing page\nlinking all available resources.\n\nExamples: \"HOMEURL=\"https://fedoraproject.org/\"\",\n\"BUGREPORTURL=\"https://bugzilla.redhat.com/\"\".\n\nLOGO=\nA string, specifying the name of an icon as defined by freedesktop.org Icon Theme\nSpecification[5]. This can be used by graphical applications to display an operating\nsystem's or distributor's logo. This field is optional and may not necessarily be\nimplemented on all systems.\n\nExamples: \"LOGO=fedora-logo\", \"LOGO=distributor-logo-opensuse\"\n\nANSICOLOR=\nA suggested presentation color when showing the OS name on the console. This should be\nspecified as string suitable for inclusion in the ESC [ m ANSI/ECMA-48 escape code for\nsetting graphical rendition. This field is optional.\n\nExamples: \"ANSICOLOR=\"0;31\"\" for red, \"ANSICOLOR=\"1;34\"\" for light blue, or\n\"ANSICOLOR=\"0;38;2;60;110;180\"\" for Fedora blue.\n"
                },
                {
                    "name": "Distribution-level defaults and metadata",
                    "content": "DEFAULTHOSTNAME=\nA string specifying the hostname if hostname(5) is not present and no other configuration\nsource specifies the hostname. Must be either a single DNS label (a string composed of\n7-bit ASCII lower-case characters and no spaces or dots, limited to the format allowed\nfor DNS domain name labels), or a sequence of such labels separated by single dots that\nforms a valid DNS FQDN. The hostname must be at most 64 characters, which is a Linux\nlimitation (DNS allows longer names).\n\nSee org.freedesktop.hostname1(5) for a description of how systemd-hostnamed.service(8)\ndetermines the fallback hostname.\n\nSYSEXTLEVEL=\nA lower-case string (mostly numeric, no spaces or other characters outside of 0–9, a–z,\n\".\", \"\" and \"-\") identifying the operating system extensions support level, to indicate\nwhich extension images are supported. See systemd-sysext(8)) for more information.\n\nExamples: \"SYSEXTLEVEL=2\", \"SYSEXTLEVEL=15.14\".\n"
                },
                {
                    "name": "Notes",
                    "content": "If you are using this file to determine the OS or a specific version of it, use the ID and\nVERSIONID fields, possibly with IDLIKE as fallback for ID. When looking for an OS\nidentification string for presentation to the user use the PRETTYNAME field.\n\nNote that operating system vendors may choose not to provide version information, for example\nto accommodate for rolling releases. In this case, VERSION and VERSIONID may be unset.\nApplications should not rely on these fields to be set.\n\nOperating system vendors may extend the file format and introduce new fields. It is highly\nrecommended to prefix new fields with an OS specific name in order to avoid name clashes.\nApplications reading this file must ignore unknown fields.\n\nExample: \"DEBIANBTS=\"debbugs://bugs.debian.org/\"\".\n\nContainer and sandbox runtime managers may make the host's identification data available to\napplications by providing the host's /etc/os-release (if available, otherwise\n/usr/lib/os-release as a fallback) as /run/host/os-release.\n"
                }
            ]
        },
        "EXAMPLES": {
            "content": "",
            "subsections": [
                {
                    "name": "Example 1. os-release file for Fedora Workstation",
                    "content": "NAME=Fedora\nVERSION=\"32 (Workstation Edition)\"\nID=fedora\nVERSIONID=32\nPRETTYNAME=\"Fedora 32 (Workstation Edition)\"\nANSICOLOR=\"0;38;2;60;110;180\"\nLOGO=fedora-logo-icon\nCPENAME=\"cpe:/o:fedoraproject:fedora:32\"\nHOMEURL=\"https://fedoraproject.org/\"\nDOCUMENTATIONURL=\"https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/\"\nSUPPORTURL=\"https://fedoraproject.org/wiki/Communicatingandgettinghelp\"\nBUGREPORTURL=\"https://bugzilla.redhat.com/\"\nREDHATBUGZILLAPRODUCT=\"Fedora\"\nREDHATBUGZILLAPRODUCTVERSION=32\nREDHATSUPPORTPRODUCT=\"Fedora\"\nREDHATSUPPORTPRODUCTVERSION=32\nPRIVACYPOLICYURL=\"https://fedoraproject.org/wiki/Legal:PrivacyPolicy\"\nVARIANT=\"Workstation Edition\"\nVARIANTID=workstation\n"
                },
                {
                    "name": "Example 2. Reading os-release in sh(1)",
                    "content": "#!/bin/sh -eu\n\ntest -e /etc/os-release && osrelease='/etc/os-release' || osrelease='/usr/lib/os-release'\n. \"${osrelease}\"\n\necho \"Running on ${PRETTYNAME:-Linux}\"\n\nif [ \"${ID:-linux}\" = \"debian\" ] || [ \"${IDLIKE#*debian*}\" != \"${IDLIKE}\" ]; then\necho \"Looks like Debian!\"\nfi\n"
                },
                {
                    "name": "Example 3. Reading os-release in python(1) (versions >= 3.10)",
                    "content": "#!/usr/bin/python\n# SPDX-License-Identifier: CC0-1.0\n\nimport platform\nosrelease = platform.freedesktoposrelease()\n\nprettyname = osrelease.get('PRETTYNAME', 'Linux')\nprint(f'Running on {prettyname!r}')\n\nif 'fedora' in [osrelease.get('ID', 'linux'),\n*osrelease.get('IDLIKE', '').split()]:\nprint('Looks like Fedora!')\n\nSee docs for platform.freedesktoposrelease[6] for more details.\n"
                },
                {
                    "name": "Example 4. Reading os-release in python(1) (any version)",
                    "content": "#!/usr/bin/python\n\nimport ast\nimport re\nimport sys\n\ndef readosrelease():\ntry:\nfilename = '/etc/os-release'\nf = open(filename)\nexcept FileNotFoundError:\nfilename = '/usr/lib/os-release'\nf = open(filename)\n\nfor linenumber, line in enumerate(f):\nline = line.rstrip()\nif not line or line.startswith('#'):\ncontinue\nif m := re.match(r'([A-Z][A-Z0-9]+)=(.*)', line):\nname, val = m.groups()\nif val and val[0] in '\"\\'':\nval = ast.literaleval(val)\nyield name, val\nelse:\nprint(f'{filename}:{linenumber + 1}: bad line {line!r}',\nfile=sys.stderr)\n\nosrelease = dict(readosrelease())\n\nprettyname = osrelease.get('PRETTYNAME', 'Linux')\nprint(f'Running on {prettyname!r}')\n\nif 'debian' in [osrelease.get('ID', 'linux'),\n*osrelease.get('IDLIKE', '').split()]:\nprint('Looks like Debian!')\n\nNote that the above version that uses the built-in implementation is preferred in most cases,\nand the open-coded version here is provided for reference.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "systemd(1), lsbrelease(1), hostname(5), machine-id(5), machine-info(5)\n",
            "subsections": []
        },
        "NOTES": {
            "content": "1. Announcement of /etc/os-release\nhttp://0pointer.de/blog/projects/os-release\n\n2. initrd\nhttps://www.kernel.org/doc/html/latest/admin-guide/initrd.html\n\n3. Common Platform Enumeration Specification\nhttp://scap.nist.gov/specifications/cpe/\n\n4. RFC3986 format\nhttps://tools.ietf.org/html/rfc3986\n\n5. freedesktop.org Icon Theme Specification\nhttp://standards.freedesktop.org/icon-theme-spec/latest\n\n6.\n\nplatform.freedesktoposrelease\nhttps://docs.python.org/3/library/platform.html#platform.freedesktoposrelease\n\n\n\nsystemd 249                                                                            OS-RELEASE(5)",
            "subsections": []
        }
    },
    "summary": "os-release, initrd-release - Operating system identification",
    "flags": [],
    "examples": [
        "NAME=Fedora",
        "VERSION=\"32 (Workstation Edition)\"",
        "ID=fedora",
        "VERSIONID=32",
        "PRETTYNAME=\"Fedora 32 (Workstation Edition)\"",
        "ANSICOLOR=\"0;38;2;60;110;180\"",
        "LOGO=fedora-logo-icon",
        "CPENAME=\"cpe:/o:fedoraproject:fedora:32\"",
        "HOMEURL=\"https://fedoraproject.org/\"",
        "DOCUMENTATIONURL=\"https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/\"",
        "SUPPORTURL=\"https://fedoraproject.org/wiki/Communicatingandgettinghelp\"",
        "BUGREPORTURL=\"https://bugzilla.redhat.com/\"",
        "REDHATBUGZILLAPRODUCT=\"Fedora\"",
        "REDHATBUGZILLAPRODUCTVERSION=32",
        "REDHATSUPPORTPRODUCT=\"Fedora\"",
        "REDHATSUPPORTPRODUCTVERSION=32",
        "PRIVACYPOLICYURL=\"https://fedoraproject.org/wiki/Legal:PrivacyPolicy\"",
        "VARIANT=\"Workstation Edition\"",
        "VARIANTID=workstation",
        "#!/bin/sh -eu",
        "test -e /etc/os-release && osrelease='/etc/os-release' || osrelease='/usr/lib/os-release'",
        ". \"${osrelease}\"",
        "echo \"Running on ${PRETTYNAME:-Linux}\"",
        "if [ \"${ID:-linux}\" = \"debian\" ] || [ \"${IDLIKE#*debian*}\" != \"${IDLIKE}\" ]; then",
        "echo \"Looks like Debian!\"",
        "fi",
        "#!/usr/bin/python",
        "# SPDX-License-Identifier: CC0-1.0",
        "import platform",
        "osrelease = platform.freedesktoposrelease()",
        "prettyname = osrelease.get('PRETTYNAME', 'Linux')",
        "print(f'Running on {prettyname!r}')",
        "if 'fedora' in [osrelease.get('ID', 'linux'),",
        "*osrelease.get('IDLIKE', '').split()]:",
        "print('Looks like Fedora!')",
        "See docs for platform.freedesktoposrelease[6] for more details.",
        "#!/usr/bin/python",
        "import ast",
        "import re",
        "import sys",
        "def readosrelease():",
        "try:",
        "filename = '/etc/os-release'",
        "f = open(filename)",
        "except FileNotFoundError:",
        "filename = '/usr/lib/os-release'",
        "f = open(filename)",
        "for linenumber, line in enumerate(f):",
        "line = line.rstrip()",
        "if not line or line.startswith('#'):",
        "continue",
        "if m := re.match(r'([A-Z][A-Z0-9]+)=(.*)', line):",
        "name, val = m.groups()",
        "if val and val[0] in '\"\\'':",
        "val = ast.literaleval(val)",
        "yield name, val",
        "else:",
        "print(f'{filename}:{linenumber + 1}: bad line {line!r}',",
        "file=sys.stderr)",
        "osrelease = dict(readosrelease())",
        "prettyname = osrelease.get('PRETTYNAME', 'Linux')",
        "print(f'Running on {prettyname!r}')",
        "if 'debian' in [osrelease.get('ID', 'linux'),",
        "*osrelease.get('IDLIKE', '').split()]:",
        "print('Looks like Debian!')",
        "Note that the above version that uses the built-in implementation is preferred in most cases,",
        "and the open-coded version here is provided for reference."
    ],
    "see_also": [
        {
            "name": "systemd",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/systemd/1/json"
        },
        {
            "name": "lsbrelease",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/lsbrelease/1/json"
        },
        {
            "name": "hostname",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/hostname/5/json"
        },
        {
            "name": "machine-id",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/machine-id/5/json"
        },
        {
            "name": "machine-info",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/machine-info/5/json"
        }
    ]
}