{
    "content": [
        {
            "type": "text",
            "text": "# OS-RELEASE (info)\n\n## NAME\n\nos-release, initrd-release - Operating system identification\n\n## SYNOPSIS\n\n/etc/os-release\n/usr/lib/os-release\n/etc/initrd-release\n\n## DESCRIPTION\n\nThe /etc/os-release and /usr/lib/os-release files contain operating\nsystem identification data.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS**\n- **EXAMPLES**\n- **SEE ALSO**\n- **NOTES**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "OS-RELEASE",
        "section": "",
        "mode": "info",
        "summary": "os-release, initrd-release - Operating system identification",
        "synopsis": "/etc/os-release\n/usr/lib/os-release\n/etc/initrd-release",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "Example 1. os-release file for Fedora Workstation",
            "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",
            "Example 2. Reading os-release in sh(1)",
            "#!/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",
            "Example 3. Reading os-release in python(1) (versions >= 3.10)",
            "#!/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.",
            "Example 4. Reading os-release in python(1) (any version)",
            "#!/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"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 51,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 236,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 94,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 21,
                "subsections": []
            }
        ],
        "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\nsystem identification data.\n\nThe basic file format of os-release is a newline-separated list of\nenvironment-like shell-compatible variable assignments. It is possible\nto source the configuration from shell scripts, however, beyond mere\nvariable assignments, no shell features are supported (this means\nvariable expansion is explicitly not supported), allowing applications\nto read the file without implementing a shell compatible execution\nengine. Variable assignment values must be enclosed in double or single\nquotes if they include spaces, semicolons or other special characters\noutside of A-Z, a-z, 0-9. Shell special characters (\"$\", quotes,\nbackslash, backtick) must be escaped with backslashes, following shell\nstyle. All strings should be in UTF-8 format, and non-printable\ncharacters should not be used. It is not supported to concatenate\nmultiple individually quoted strings. Lines beginning with \"#\" shall be\nignored as comments. Blank lines are permitted and ignored.\n\nThe file /etc/os-release takes precedence over /usr/lib/os-release.\nApplications should check for the former, and exclusively use its data\nif it exists, and only fall back to /usr/lib/os-release if it is\nmissing. Applications should not read data from both files at the same\ntime.  /usr/lib/os-release is the recommended place to store OS release\ninformation as part of vendor trees.  /etc/os-release should be a\nrelative symlink to /usr/lib/os-release, to provide compatibility with\napplications only looking at /etc/. A relative symlink instead of an\nabsolute symlink is necessary to avoid breaking the link in a chroot or\ninitrd environment such as dracut.\n\nos-release contains data that is defined by the operating system vendor\nand should generally not be changed by the administrator.\n\nAs this file only encodes names and identifiers it should not be\nlocalized.\n\nThe /etc/os-release and /usr/lib/os-release files might be symlinks to\nother files, but it is important that the file is available from\nearliest boot on, and hence must be located on the root file system.\n\nFor a longer rationale for os-release please refer to the Announcement\nof /etc/os-release[1].\n\n/etc/initrd-release\nIn the initrd[2], /etc/initrd-release plays the same role as os-release\nin the main system. Additionally, the presence of that file means that\nthe system is in the initrd phase.  /etc/os-release should be symlinked\nto /etc/initrd-release (or vice versa), so programs that only look for\n/etc/os-release (as described above) work correctly. The rest of this\ndocument that talks about os-release should be understood to apply to\ninitrd-release too.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "The following OS identifications parameters may be set using\nos-release:\n\nGeneral information identifying the operating system\nNAME=\nA string identifying the operating system, without a version\ncomponent, and suitable for presentation to the user. If not set, a\ndefault 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,\na-z, \".\", \"\" and \"-\") identifying the operating system, excluding\nany version information and suitable for processing by scripts or\nusage in generated filenames. If not set, a default of \"ID=linux\"\nmay be used.\n\nExamples: \"ID=fedora\", \"ID=debian\".\n\nIDLIKE=\nA space-separated list of operating system identifiers in the same\nsyntax as the ID= setting. It should list identifiers of operating\nsystems that are closely related to the local operating system in\nregards to packaging and programming interfaces, for example\nlisting one or more OS identifiers the local OS is a derivative\nfrom. An OS should generally only list other OS identifiers it\nitself is a derivative of, and not any OSes that are derived from\nit, though symmetric relationships are possible. Build scripts and\nsimilar should check this variable if they need to identify the\nlocal operating system and the value of ID= is not recognized.\nOperating systems should be listed in order of how closely the\nlocal operating system relates to the listed ones, starting with\nthe closest. This field is optional.\n\nExamples: for an operating system with \"ID=centos\", an assignment\nof \"IDLIKE=\"rhel fedora\"\" would be appropriate. For an operating\nsystem with \"ID=ubuntu\", an assignment of \"IDLIKE=debian\" is\nappropriate.\n\nPRETTYNAME=\nA pretty operating system name in a format suitable for\npresentation to the user. May or may not contain a release code\nname or OS version of some kind, as suitable. If not set, a default\nof \"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,\nfollowing the Common Platform Enumeration Specification[3] as\nproposed 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\nsystem suitable for presentation to the user. This field may be\nused to inform the user that the configuration of this system is\nsubject to a specific divergent set of rules or default\nconfiguration settings. This field is optional and may not be\nimplemented on all systems.\n\nExamples: \"VARIANT=\"Server Edition\"\", \"VARIANT=\"Smart Refrigerator\nEdition\"\".\n\nNote: this field is for display purposes only. The VARIANTID field\nshould be used for making programmatic decisions.\n\nVARIANTID=\nA lower-case string (no spaces or other characters outside of 0-9,\na-z, \".\", \"\" and \"-\"), identifying a specific variant or edition\nof the operating system. This may be interpreted by other packages\nin order to determine a divergent default configuration. This field\nis optional and may not be implemented on all systems.\n\nExamples: \"VARIANTID=server\", \"VARIANTID=embedded\".\n\nInformation about the version of the operating system\nVERSION=\nA string identifying the operating system version, excluding any OS\nname information, possibly including a release code name, and\nsuitable for presentation to the user. This field is optional.\n\nExamples: \"VERSION=17\", \"VERSION=\"17 (Beefy Miracle)\"\".\n\nVERSIONID=\nA lower-case string (mostly numeric, no spaces or other characters\noutside of 0-9, a-z, \".\", \"\" and \"-\") identifying the operating\nsystem version, excluding any OS name information or release code\nname, and suitable for processing by scripts or usage in generated\nfilenames. 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,\na-z, \".\", \"\" and \"-\") identifying the operating system release\ncode name, excluding any OS name information or release version,\nand suitable for processing by scripts or usage in generated\nfilenames. This field is optional and may not be implemented on all\nsystems.\n\nExamples: \"VERSIONCODENAME=buster\", \"VERSIONCODENAME=xenial\".\n\nBUILDID=\nA string uniquely identifying the system image originally used as\nthe installation base. In most cases, VERSIONID or\nIMAGEID+IMAGEVERSION are updated when the entire system image is\nreplaced during an update.  BUILDID may be used in distributions\nwhere the original installation image version is important:\nVERSIONID would change during incremental system updates, but\nBUILDID 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,\na-z, \".\", \"\" and \"-\"), identifying a specific image of the\noperating system. This is supposed to be used for environments\nwhere OS images are prepared, built, shipped and updated as\ncomprehensive, consistent OS images. This field is optional and may\nnot be implemented on all systems, in particularly not on those\nthat are not managed via images but put together and updated from\nindividual packages and on the local system.\n\nExamples: \"IMAGEID=vendorx-cashier-system\",\n\"IMAGEID=netbook-image\".\n\nIMAGEVERSION=\nA lower-case string (mostly numeric, no spaces or other characters\noutside of 0-9, a-z, \".\", \"\" and \"-\") identifying the OS image\nversion. This is supposed to be used together with IMAGEID\ndescribed 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\ncomprehensive units, IMAGEID+IMAGEVERSION is the best fit. Otherwise,\nif updates eventually completely replace previously installed contents,\nas in a typical binary distribution, VERSIONID should be used to\nidentify major releases of the operating system.  BUILDID may be used\ninstead or in addition to VERSIONID when the original system image\nversion is important.\n\nPresentation information and links\nHOMEURL=, DOCUMENTATIONURL=, SUPPORTURL=, BUGREPORTURL=,\nPRIVACYPOLICYURL=\nLinks to resources on the Internet related to the operating system.\nHOMEURL= should refer to the homepage of the operating system, or\nalternatively some homepage of the specific version of the\noperating system.  DOCUMENTATIONURL= should refer to the main\ndocumentation page for this operating system.  SUPPORTURL= should\nrefer to the main support page for the operating system, if there\nis any. This is primarily intended for operating systems which\nvendors provide support for.  BUGREPORTURL= should refer to the\nmain bug reporting page for the operating system, if there is any.\nThis is primarily intended for operating systems that rely on\ncommunity QA.  PRIVACYPOLICYURL= should refer to the main privacy\npolicy page for the operating system, if there is any. These\nsettings are optional, and providing only some of these settings is\ncommon. These URLs are intended to be exposed in \"About this\nsystem\" UIs behind links with captions such as \"About this\nOperating System\", \"Obtain Support\", \"Report a Bug\", or \"Privacy\nPolicy\". The values should be in RFC3986 format[4], and should be\n\"http:\" or \"https:\" URLs, and possibly \"mailto:\" or \"tel:\". Only\none URL shall be listed in each setting. If multiple resources need\nto be referenced, it is recommended to provide an online landing\npage linking 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\nfreedesktop.org Icon Theme Specification[5]. This can be used by\ngraphical applications to display an operating system's or\ndistributor's logo. This field is optional and may not necessarily\nbe implemented 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\nconsole. This should be specified as string suitable for inclusion\nin the ESC [ m ANSI/ECMA-48 escape code for setting graphical\nrendition. This field is optional.\n\nExamples: \"ANSICOLOR=\"0;31\"\" for red, \"ANSICOLOR=\"1;34\"\" for\nlight blue, or \"ANSICOLOR=\"0;38;2;60;110;180\"\" for Fedora blue.\n\nDistribution-level defaults and metadata\nDEFAULTHOSTNAME=\nA string specifying the hostname if hostname(5) is not present and\nno other configuration source specifies the hostname. Must be\neither a single DNS label (a string composed of 7-bit ASCII\nlower-case characters and no spaces or dots, limited to the format\nallowed for DNS domain name labels), or a sequence of such labels\nseparated by single dots that forms a valid DNS FQDN. The hostname\nmust be at most 64 characters, which is a Linux limitation (DNS\nallows longer names).\n\nSee org.freedesktop.hostname1(5) for a description of how systemd-\nhostnamed.service(8) determines the fallback hostname.\n\nSYSEXTLEVEL=\nA lower-case string (mostly numeric, no spaces or other characters\noutside of 0-9, a-z, \".\", \"\" and \"-\") identifying the operating\nsystem extensions support level, to indicate which extension images\nare supported. See systemd-sysext(8)) for more information.\n\nExamples: \"SYSEXTLEVEL=2\", \"SYSEXTLEVEL=15.14\".\n\nNotes\nIf you are using this file to determine the OS or a specific version of\nit, use the ID and VERSIONID fields, possibly with IDLIKE as fallback\nfor ID. When looking for an OS identification string for presentation\nto the user use the PRETTYNAME field.\n\nNote that operating system vendors may choose not to provide version\ninformation, for example to accommodate for rolling releases. In this\ncase, VERSION and VERSIONID may be unset. Applications should not rely\non these fields to be set.\n\nOperating system vendors may extend the file format and introduce new\nfields. It is highly recommended to prefix new fields with an OS\nspecific name in order to avoid name clashes. Applications reading this\nfile must ignore unknown fields.\n\nExample: \"DEBIANBTS=\"debbugs://bugs.debian.org/\"\".\n\nContainer and sandbox runtime managers may make the host's\nidentification data available to applications by providing the host's\n/etc/os-release (if available, otherwise /usr/lib/os-release as a\nfallback) as /run/host/os-release.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "Example 1. os-release file for Fedora Workstation\n\nNAME=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\nExample 2. Reading os-release in sh(1)\n\n#!/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\nExample 3. Reading os-release in python(1) (versions >= 3.10)\n\n#!/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\nExample 4. Reading os-release in python(1) (any version)\n\n#!/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\npreferred in most cases, and the open-coded version here is provided\nfor reference.\n",
                "subsections": []
            },
            "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\nsystemd 249                                                      OS-RELEASE(5)",
                "subsections": []
            }
        }
    }
}