1OS-RELEASE(5)                     os-release                     OS-RELEASE(5)
2
3
4

NAME

6       os-release, initrd-release, extension-release - Operating system
7       identification
8

SYNOPSIS

10       /etc/os-release
11
12       /usr/lib/os-release
13
14       /etc/initrd-release
15
16       /usr/lib/extension-release.d/extension-release.IMAGE
17

DESCRIPTION

19       The /etc/os-release and /usr/lib/os-release files contain operating
20       system identification data.
21
22       The format of os-release is a newline-separated list of
23       environment-like shell-compatible variable assignments. It is possible
24       to source the configuration from Bourne shell scripts, however, beyond
25       mere variable assignments, no shell features are supported (this means
26       variable expansion is explicitly not supported), allowing applications
27       to read the file without implementing a shell compatible execution
28       engine. Variable assignment values must be enclosed in double or single
29       quotes if they include spaces, semicolons or other special characters
30       outside of A–Z, a–z, 0–9. (Assignments that do not include these
31       special characters may be enclosed in quotes too, but this is
32       optional.) Shell special characters ("$", quotes, backslash, backtick)
33       must be escaped with backslashes, following shell style. All strings
34       should be in UTF-8 encoding, and non-printable characters should not be
35       used. Concatenation of multiple individually quoted strings is not
36       supported. Lines beginning with "#" are treated as comments. Blank
37       lines are permitted and ignored.
38
39       The file /etc/os-release takes precedence over /usr/lib/os-release.
40       Applications should check for the former, and exclusively use its data
41       if it exists, and only fall back to /usr/lib/os-release if it is
42       missing. Applications should not read data from both files at the same
43       time.  /usr/lib/os-release is the recommended place to store OS release
44       information as part of vendor trees.  /etc/os-release should be a
45       relative symlink to /usr/lib/os-release, to provide compatibility with
46       applications only looking at /etc/. A relative symlink instead of an
47       absolute symlink is necessary to avoid breaking the link in a chroot or
48       initrd environment such as dracut.
49
50       os-release contains data that is defined by the operating system vendor
51       and should generally not be changed by the administrator.
52
53       As this file only encodes names and identifiers it should not be
54       localized.
55
56       The /etc/os-release and /usr/lib/os-release files might be symlinks to
57       other files, but it is important that the file is available from
58       earliest boot on, and hence must be located on the root file system.
59
60       os-release must not contain repeating keys. Nevertheless, readers
61       should pick the entries later in the file in case of repeats, similarly
62       to how a shell sourcing the file would. A reader may warn about
63       repeating entries.
64
65       For a longer rationale for os-release please refer to the Announcement
66       of /etc/os-release[1].
67
68   /etc/initrd-release
69       In the initrd[2], /etc/initrd-release plays the same role as os-release
70       in the main system. Additionally, the presence of that file means that
71       the system is in the initrd phase.  /etc/os-release should be symlinked
72       to /etc/initrd-release (or vice versa), so programs that only look for
73       /etc/os-release (as described above) work correctly.
74
75       The rest of this document that talks about os-release should be
76       understood to apply to initrd-release too.
77
78   /usr/lib/extension-release.d/extension-release.IMAGE
79       /usr/lib/extension-release.d/extension-release.IMAGE plays the same
80       role for extension images as os-release for the main system, and
81       follows the syntax and rules as described in the Portable Services
82       Documentation[3]. The purpose of this file is to identify the extension
83       and to allow the operating system to verify that the extension image
84       matches the base OS. This is typically implemented by checking that the
85       ID= options match, and either SYSEXT_LEVEL= exists and matches too, or
86       if it is not present, VERSION_ID= exists and matches. This ensures
87       ABI/API compatibility between the layers and prevents merging of an
88       incompatible image in an overlay.
89
90       In order to identify the extension image itself, the same fields
91       defined below can be added to the extension-release file with a SYSEXT_
92       prefix (to disambiguate from fields used to match on the base image).
93       E.g.: SYSEXT_ID=myext, SYSEXT_VERSION_ID=1.2.3.
94
95       In the extension-release.IMAGE filename, the IMAGE part must exactly
96       match the file name of the containing image with the suffix removed. In
97       case it is not possible to guarantee that an image file name is stable
98       and doesn't change between the build and the deployment phases, it is
99       possible to relax this check: if exactly one file whose name matches
100       "extension-release.*"  is present in this directory, and the file is
101       tagged with a user.extension-release.strict xattr(7) set to the string
102       "0", it will be used instead.
103
104       The rest of this document that talks about os-release should be
105       understood to apply to extension-release too.
106

OPTIONS

108       The following OS identifications parameters may be set using
109       os-release:
110
111   General information identifying the operating system
112       NAME=
113           A string identifying the operating system, without a version
114           component, and suitable for presentation to the user. If not set, a
115           default of "NAME=Linux" may be used.
116
117           Examples: "NAME=Fedora", "NAME="Debian GNU/Linux"".
118
119       ID=
120           A lower-case string (no spaces or other characters outside of 0–9,
121           a–z, ".", "_" and "-") identifying the operating system, excluding
122           any version information and suitable for processing by scripts or
123           usage in generated filenames. If not set, a default of "ID=linux"
124           may be used. Note that even though this string may not include
125           characters that require shell quoting, quoting may nevertheless be
126           used.
127
128           Examples: "ID=fedora", "ID=debian".
129
130       ID_LIKE=
131           A space-separated list of operating system identifiers in the same
132           syntax as the ID= setting. It should list identifiers of operating
133           systems that are closely related to the local operating system in
134           regards to packaging and programming interfaces, for example
135           listing one or more OS identifiers the local OS is a derivative
136           from. An OS should generally only list other OS identifiers it
137           itself is a derivative of, and not any OSes that are derived from
138           it, though symmetric relationships are possible. Build scripts and
139           similar should check this variable if they need to identify the
140           local operating system and the value of ID= is not recognized.
141           Operating systems should be listed in order of how closely the
142           local operating system relates to the listed ones, starting with
143           the closest. This field is optional.
144
145           Examples: for an operating system with "ID=centos", an assignment
146           of "ID_LIKE="rhel fedora"" would be appropriate. For an operating
147           system with "ID=ubuntu", an assignment of "ID_LIKE=debian" is
148           appropriate.
149
150       PRETTY_NAME=
151           A pretty operating system name in a format suitable for
152           presentation to the user. May or may not contain a release code
153           name or OS version of some kind, as suitable. If not set, a default
154           of "PRETTY_NAME="Linux"" may be used
155
156           Example: "PRETTY_NAME="Fedora 17 (Beefy Miracle)"".
157
158       CPE_NAME=
159           A CPE name for the operating system, in URI binding syntax,
160           following the Common Platform Enumeration Specification[4] as
161           proposed by the NIST. This field is optional.
162
163           Example: "CPE_NAME="cpe:/o:fedoraproject:fedora:17""
164
165       VARIANT=
166           A string identifying a specific variant or edition of the operating
167           system suitable for presentation to the user. This field may be
168           used to inform the user that the configuration of this system is
169           subject to a specific divergent set of rules or default
170           configuration settings. This field is optional and may not be
171           implemented on all systems.
172
173           Examples: "VARIANT="Server Edition"", "VARIANT="Smart Refrigerator
174           Edition"".
175
176           Note: this field is for display purposes only. The VARIANT_ID field
177           should be used for making programmatic decisions.
178
179       VARIANT_ID=
180           A lower-case string (no spaces or other characters outside of 0–9,
181           a–z, ".", "_" and "-"), identifying a specific variant or edition
182           of the operating system. This may be interpreted by other packages
183           in order to determine a divergent default configuration. This field
184           is optional and may not be implemented on all systems.
185
186           Examples: "VARIANT_ID=server", "VARIANT_ID=embedded".
187
188   Information about the version of the operating system
189       VERSION=
190           A string identifying the operating system version, excluding any OS
191           name information, possibly including a release code name, and
192           suitable for presentation to the user. This field is optional.
193
194           Examples: "VERSION=17", "VERSION="17 (Beefy Miracle)"".
195
196       VERSION_ID=
197           A lower-case string (mostly numeric, no spaces or other characters
198           outside of 0–9, a–z, ".", "_" and "-") identifying the operating
199           system version, excluding any OS name information or release code
200           name, and suitable for processing by scripts or usage in generated
201           filenames. This field is optional.
202
203           Examples: "VERSION_ID=17", "VERSION_ID=11.04".
204
205       VERSION_CODENAME=
206           A lower-case string (no spaces or other characters outside of 0–9,
207           a–z, ".", "_" and "-") identifying the operating system release
208           code name, excluding any OS name information or release version,
209           and suitable for processing by scripts or usage in generated
210           filenames. This field is optional and may not be implemented on all
211           systems.
212
213           Examples: "VERSION_CODENAME=buster", "VERSION_CODENAME=xenial".
214
215       BUILD_ID=
216           A string uniquely identifying the system image originally used as
217           the installation base. In most cases, VERSION_ID or
218           IMAGE_ID+IMAGE_VERSION are updated when the entire system image is
219           replaced during an update.  BUILD_ID may be used in distributions
220           where the original installation image version is important:
221           VERSION_ID would change during incremental system updates, but
222           BUILD_ID would not. This field is optional.
223
224           Examples: "BUILD_ID="2013-03-20.3"", "BUILD_ID=201303203".
225
226       IMAGE_ID=
227           A lower-case string (no spaces or other characters outside of 0–9,
228           a–z, ".", "_" and "-"), identifying a specific image of the
229           operating system. This is supposed to be used for environments
230           where OS images are prepared, built, shipped and updated as
231           comprehensive, consistent OS images. This field is optional and may
232           not be implemented on all systems, in particularly not on those
233           that are not managed via images but put together and updated from
234           individual packages and on the local system.
235
236           Examples: "IMAGE_ID=vendorx-cashier-system",
237           "IMAGE_ID=netbook-image".
238
239       IMAGE_VERSION=
240           A lower-case string (mostly numeric, no spaces or other characters
241           outside of 0–9, a–z, ".", "_" and "-") identifying the OS image
242           version. This is supposed to be used together with IMAGE_ID
243           described above, to discern different versions of the same image.
244
245           Examples: "IMAGE_VERSION=33", "IMAGE_VERSION=47.1rc1".
246
247       To summarize: if the image updates are built and shipped as
248       comprehensive units, IMAGE_ID+IMAGE_VERSION is the best fit. Otherwise,
249       if updates eventually completely replace previously installed contents,
250       as in a typical binary distribution, VERSION_ID should be used to
251       identify major releases of the operating system.  BUILD_ID may be used
252       instead or in addition to VERSION_ID when the original system image
253       version is important.
254
255   Presentation information and links
256       HOME_URL=, DOCUMENTATION_URL=, SUPPORT_URL=, BUG_REPORT_URL=,
257       PRIVACY_POLICY_URL=
258           Links to resources on the Internet related to the operating system.
259           HOME_URL= should refer to the homepage of the operating system, or
260           alternatively some homepage of the specific version of the
261           operating system.  DOCUMENTATION_URL= should refer to the main
262           documentation page for this operating system.  SUPPORT_URL= should
263           refer to the main support page for the operating system, if there
264           is any. This is primarily intended for operating systems which
265           vendors provide support for.  BUG_REPORT_URL= should refer to the
266           main bug reporting page for the operating system, if there is any.
267           This is primarily intended for operating systems that rely on
268           community QA.  PRIVACY_POLICY_URL= should refer to the main privacy
269           policy page for the operating system, if there is any. These
270           settings are optional, and providing only some of these settings is
271           common. These URLs are intended to be exposed in "About this
272           system" UIs behind links with captions such as "About this
273           Operating System", "Obtain Support", "Report a Bug", or "Privacy
274           Policy". The values should be in RFC3986 format[5], and should be
275           "http:" or "https:" URLs, and possibly "mailto:" or "tel:". Only
276           one URL shall be listed in each setting. If multiple resources need
277           to be referenced, it is recommended to provide an online landing
278           page linking all available resources.
279
280           Examples: "HOME_URL="https://fedoraproject.org/"",
281           "BUG_REPORT_URL="https://bugzilla.redhat.com/"".
282
283       SUPPORT_END=
284           The date at which support for this version of the OS ends. (What
285           exactly "lack of support" means varies between vendors, but
286           generally users should assume that updates, including security
287           fixes, will not be provided.) The value is a date in the ISO 8601
288           format "YYYY-MM-DD", and specifies the first day on which support
289           is not provided.
290
291           For example, "SUPPORT_END=2001-01-01" means that the system was
292           supported until the end of the last day of the previous millennium.
293
294       LOGO=
295           A string, specifying the name of an icon as defined by
296           freedesktop.org Icon Theme Specification[6]. This can be used by
297           graphical applications to display an operating system's or
298           distributor's logo. This field is optional and may not necessarily
299           be implemented on all systems.
300
301           Examples: "LOGO=fedora-logo", "LOGO=distributor-logo-opensuse"
302
303       ANSI_COLOR=
304           A suggested presentation color when showing the OS name on the
305           console. This should be specified as string suitable for inclusion
306           in the ESC [ m ANSI/ECMA-48 escape code for setting graphical
307           rendition. This field is optional.
308
309           Examples: "ANSI_COLOR="0;31"" for red, "ANSI_COLOR="1;34"" for
310           light blue, or "ANSI_COLOR="0;38;2;60;110;180"" for Fedora blue.
311
312       VENDOR_NAME=
313           The name of the OS vendor. This is the name of the organization or
314           company which produces the OS. This field is optional.
315
316           This name is intended to be exposed in "About this system" UIs or
317           software update UIs when needed to distinguish the OS vendor from
318           the OS itself. It is intended to be human readable.
319
320           Examples: "VENDOR_NAME="Fedora Project"" for Fedora Linux,
321           "VENDOR_NAME="Canonical"" for Ubuntu.
322
323       VENDOR_URL=
324           The homepage of the OS vendor. This field is optional. The
325           VENDOR_NAME= field should be set if this one is, although clients
326           must be robust against either field not being set.
327
328           The value should be in RFC3986 format[5], and should be "http:" or
329           "https:" URLs. Only one URL shall be listed in the setting.
330
331           Examples: "VENDOR_URL="https://fedoraproject.org/"",
332           "VENDOR_URL="https://canonical.com/"".
333
334   Distribution-level defaults and metadata
335       DEFAULT_HOSTNAME=
336           A string specifying the hostname if hostname(5) is not present and
337           no other configuration source specifies the hostname. Must be
338           either a single DNS label (a string composed of 7-bit ASCII
339           lower-case characters and no spaces or dots, limited to the format
340           allowed for DNS domain name labels), or a sequence of such labels
341           separated by single dots that forms a valid DNS FQDN. The hostname
342           must be at most 64 characters, which is a Linux limitation (DNS
343           allows longer names).
344
345           See org.freedesktop.hostname1(5) for a description of how systemd-
346           hostnamed.service(8) determines the fallback hostname.
347
348       ARCHITECTURE=
349           A string that specifies which CPU architecture the userspace
350           binaries require. The architecture identifiers are the same as for
351           ConditionArchitecture= described in systemd.unit(5). The field is
352           optional and should only be used when just single architecture is
353           supported. It may provide redundant information when used in a GPT
354           partition with a GUID type that already encodes the architecture.
355           If this is not the case, the architecture should be specified in
356           e.g., an extension image, to prevent an incompatible host from
357           loading it.
358
359       SYSEXT_LEVEL=
360           A lower-case string (mostly numeric, no spaces or other characters
361           outside of 0–9, a–z, ".", "_" and "-") identifying the operating
362           system extensions support level, to indicate which extension images
363           are supported. See
364           /usr/lib/extension-release.d/extension-release.IMAGE, initrd[2] and
365           systemd-sysext(8)) for more information.
366
367           Examples: "SYSEXT_LEVEL=2", "SYSEXT_LEVEL=15.14".
368
369       CONFEXT_LEVEL=
370           Semantically the same as SYSEXT_LEVEL= but for confext images. See
371           /etc/extension-release.d/extension-release.IMAGE for more
372           information.
373
374           Examples: "CONFEXT_LEVEL=2", "CONFEXT_LEVEL=15.14".
375
376       SYSEXT_SCOPE=
377           Takes a space-separated list of one or more of the strings
378           "system", "initrd" and "portable". This field is only supported in
379           extension-release.d/ files and indicates what environments the
380           system extension is applicable to: i.e. to regular systems, to
381           initrds, or to portable service images. If unspecified,
382           "SYSEXT_SCOPE=system portable" is implied, i.e. any system
383           extension without this field is applicable to regular systems and
384           to portable service environments, but not to initrd environments.
385
386       CONFEXT_SCOPE=
387           Semantically the same as SYSEXT_SCOPE= but for confext images.
388
389       PORTABLE_PREFIXES=
390           Takes a space-separated list of one or more valid prefix match
391           strings for the Portable Services Documentation[3] logic. This
392           field serves two purposes: it is informational, identifying
393           portable service images as such (and thus allowing them to be
394           distinguished from other OS images, such as bootable system
395           images). It is also used when a portable service image is attached:
396           the specified or implied portable service prefix is checked against
397           the list specified here, to enforce restrictions how images may be
398           attached to a system.
399
400   Notes
401       If you are using this file to determine the OS or a specific version of
402       it, use the ID and VERSION_ID fields, possibly with ID_LIKE as fallback
403       for ID. When looking for an OS identification string for presentation
404       to the user use the PRETTY_NAME field.
405
406       Note that operating system vendors may choose not to provide version
407       information, for example to accommodate for rolling releases. In this
408       case, VERSION and VERSION_ID may be unset. Applications should not rely
409       on these fields to be set.
410
411       Operating system vendors may extend the file format and introduce new
412       fields. It is highly recommended to prefix new fields with an OS
413       specific name in order to avoid name clashes. Applications reading this
414       file must ignore unknown fields.
415
416       Example: "DEBIAN_BTS="debbugs://bugs.debian.org/"".
417
418       Container and sandbox runtime managers may make the host's
419       identification data available to applications by providing the host's
420       /etc/os-release (if available, otherwise /usr/lib/os-release as a
421       fallback) as /run/host/os-release.
422

EXAMPLES

424       Example 1. os-release file for Fedora Workstation
425
426           NAME=Fedora
427           VERSION="32 (Workstation Edition)"
428           ID=fedora
429           VERSION_ID=32
430           PRETTY_NAME="Fedora 32 (Workstation Edition)"
431           ANSI_COLOR="0;38;2;60;110;180"
432           LOGO=fedora-logo-icon
433           CPE_NAME="cpe:/o:fedoraproject:fedora:32"
434           HOME_URL="https://fedoraproject.org/"
435           DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/"
436           SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
437           BUG_REPORT_URL="https://bugzilla.redhat.com/"
438           REDHAT_BUGZILLA_PRODUCT="Fedora"
439           REDHAT_BUGZILLA_PRODUCT_VERSION=32
440           REDHAT_SUPPORT_PRODUCT="Fedora"
441           REDHAT_SUPPORT_PRODUCT_VERSION=32
442           PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
443           VARIANT="Workstation Edition"
444           VARIANT_ID=workstation
445
446       Example 2. extension-release file for an extension for Fedora
447       Workstation 32
448
449           ID=fedora
450           VERSION_ID=32
451
452       Example 3. Reading os-release in sh(1)
453
454           #!/bin/sh -eu
455           # SPDX-License-Identifier: MIT-0
456
457           test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
458           . "${os_release}"
459
460           echo "Running on ${PRETTY_NAME:-Linux}"
461
462           if [ "${ID:-linux}" = "debian" ] || [ "${ID_LIKE#*debian*}" != "${ID_LIKE}" ]; then
463               echo "Looks like Debian!"
464           fi
465
466       Example 4. Reading os-release in python(1) (versions >= 3.10)
467
468           #!/usr/bin/python
469           # SPDX-License-Identifier: MIT-0
470
471           import platform
472           os_release = platform.freedesktop_os_release()
473
474           pretty_name = os_release.get('PRETTY_NAME', 'Linux')
475           print(f'Running on {pretty_name!r}')
476
477           if 'fedora' in [os_release.get('ID', 'linux'),
478                           *os_release.get('ID_LIKE', '').split()]:
479               print('Looks like Fedora!')
480
481       See docs for platform.freedesktop_os_release[7] for more details.
482
483       Example 5. Reading os-release in python(1) (any version)
484
485           #!/usr/bin/python
486           # SPDX-License-Identifier: MIT-0
487
488           import ast
489           import re
490           import sys
491
492           def read_os_release():
493               try:
494                   filename = '/etc/os-release'
495                   f = open(filename)
496               except FileNotFoundError:
497                   filename = '/usr/lib/os-release'
498                   f = open(filename)
499
500               for line_number, line in enumerate(f, start=1):
501                   line = line.rstrip()
502                   if not line or line.startswith('#'):
503                       continue
504                   m = re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line)
505                   if m:
506                       name, val = m.groups()
507                       if val and val[0] in '"\'':
508                           val = ast.literal_eval(val)
509                       yield name, val
510                   else:
511                       print(f'{filename}:{line_number}: bad line {line!r}',
512                             file=sys.stderr)
513
514           os_release = dict(read_os_release())
515
516           pretty_name = os_release.get('PRETTY_NAME', 'Linux')
517           print(f'Running on {pretty_name!r}')
518
519           if 'debian' in [os_release.get('ID', 'linux'),
520                           *os_release.get('ID_LIKE', '').split()]:
521               print('Looks like Debian!')
522
523       Note that the above version that uses the built-in implementation is
524       preferred in most cases, and the open-coded version here is provided
525       for reference.
526

SEE ALSO

528       systemd(1), lsb_release(1), hostname(5), machine-id(5), machine-info(5)
529

NOTES

531        1. Announcement of /etc/os-release
532           https://0pointer.de/blog/projects/os-release
533
534        2. initrd
535           https://docs.kernel.org/admin-guide/initrd.html
536
537        3. Portable Services Documentation
538           https://systemd.io/PORTABLE_SERVICES
539
540        4. Common Platform Enumeration Specification
541           http://scap.nist.gov/specifications/cpe/
542
543        5. RFC3986 format
544           https://tools.ietf.org/html/rfc3986
545
546        6. freedesktop.org Icon Theme Specification
547           https://standards.freedesktop.org/icon-theme-spec/latest
548
549        7.
550
551                 platform.freedesktop_os_release
552           https://docs.python.org/3/library/platform.html#platform.freedesktop_os_release
553
554
555
556systemd 254                                                      OS-RELEASE(5)
Impressum