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 the extension-release.IMAGE filename, the IMAGE part must exactly
91       match the file name of the containing image with the suffix removed. In
92       case it is not possible to guarantee that an image file name is stable
93       and doesn't change between the build and the deployment phases, it is
94       possible to relax this check: if exactly one file whose name matches
95       "extension-release.*"  is present in this directory, and the file is
96       tagged with a user.extension-release.strict xattr(7) set to the string
97       "0", it will be used instead.
98
99       The rest of this document that talks about os-release should be
100       understood to apply to extension-release too.
101

OPTIONS

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

EXAMPLES

365       Example 1. os-release file for Fedora Workstation
366
367           NAME=Fedora
368           VERSION="32 (Workstation Edition)"
369           ID=fedora
370           VERSION_ID=32
371           PRETTY_NAME="Fedora 32 (Workstation Edition)"
372           ANSI_COLOR="0;38;2;60;110;180"
373           LOGO=fedora-logo-icon
374           CPE_NAME="cpe:/o:fedoraproject:fedora:32"
375           HOME_URL="https://fedoraproject.org/"
376           DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/"
377           SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
378           BUG_REPORT_URL="https://bugzilla.redhat.com/"
379           REDHAT_BUGZILLA_PRODUCT="Fedora"
380           REDHAT_BUGZILLA_PRODUCT_VERSION=32
381           REDHAT_SUPPORT_PRODUCT="Fedora"
382           REDHAT_SUPPORT_PRODUCT_VERSION=32
383           PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
384           VARIANT="Workstation Edition"
385           VARIANT_ID=workstation
386
387       Example 2. extension-release file for an extension for Fedora
388       Workstation 32
389
390           ID=fedora
391           VERSION_ID=32
392
393       Example 3. Reading os-release in sh(1)
394
395           #!/bin/sh -eu
396           # SPDX-License-Identifier: CC0-1.0
397
398           test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
399           . "${os_release}"
400
401           echo "Running on ${PRETTY_NAME:-Linux}"
402
403           if [ "${ID:-linux}" = "debian" ] || [ "${ID_LIKE#*debian*}" != "${ID_LIKE}" ]; then
404               echo "Looks like Debian!"
405           fi
406
407       Example 4. Reading os-release in python(1) (versions >= 3.10)
408
409           #!/usr/bin/python
410           # SPDX-License-Identifier: CC0-1.0
411
412           import platform
413           os_release = platform.freedesktop_os_release()
414
415           pretty_name = os_release.get('PRETTY_NAME', 'Linux')
416           print(f'Running on {pretty_name!r}')
417
418           if 'fedora' in [os_release.get('ID', 'linux'),
419                           *os_release.get('ID_LIKE', '').split()]:
420               print('Looks like Fedora!')
421
422       See docs for platform.freedesktop_os_release[7] for more details.
423
424       Example 5. Reading os-release in python(1) (any version)
425
426           #!/usr/bin/python
427           # SPDX-License-Identifier: CC0-1.0
428
429           import ast
430           import re
431           import sys
432
433           def read_os_release():
434               try:
435                   filename = '/etc/os-release'
436                   f = open(filename)
437               except FileNotFoundError:
438                   filename = '/usr/lib/os-release'
439                   f = open(filename)
440
441               for line_number, line in enumerate(f, start=1):
442                   line = line.rstrip()
443                   if not line or line.startswith('#'):
444                       continue
445                   m = re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line)
446                   if m:
447                       name, val = m.groups()
448                       if val and val[0] in '"\'':
449                           val = ast.literal_eval(val)
450                       yield name, val
451                   else:
452                       print(f'{filename}:{line_number}: bad line {line!r}',
453                             file=sys.stderr)
454
455           os_release = dict(read_os_release())
456
457           pretty_name = os_release.get('PRETTY_NAME', 'Linux')
458           print(f'Running on {pretty_name!r}')
459
460           if 'debian' in [os_release.get('ID', 'linux'),
461                           *os_release.get('ID_LIKE', '').split()]:
462               print('Looks like Debian!')
463
464       Note that the above version that uses the built-in implementation is
465       preferred in most cases, and the open-coded version here is provided
466       for reference.
467

SEE ALSO

469       systemd(1), lsb_release(1), hostname(5), machine-id(5), machine-info(5)
470

NOTES

472        1. Announcement of /etc/os-release
473           http://0pointer.de/blog/projects/os-release
474
475        2. initrd
476           https://www.kernel.org/doc/html/latest/admin-guide/initrd.html
477
478        3. Portable Services Documentation
479           https://systemd.io/PORTABLE_SERVICES
480
481        4. Common Platform Enumeration Specification
482           http://scap.nist.gov/specifications/cpe/
483
484        5. RFC3986 format
485           https://tools.ietf.org/html/rfc3986
486
487        6. freedesktop.org Icon Theme Specification
488           http://standards.freedesktop.org/icon-theme-spec/latest
489
490        7.
491
492                 platform.freedesktop_os_release
493           https://docs.python.org/3/library/platform.html#platform.freedesktop_os_release
494
495
496
497systemd 251                                                      OS-RELEASE(5)
Impressum