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       SUPPORT_END=
279           The date at which support for this version of the OS ends. (What
280           exactly "lack of support" means varies between vendors, but
281           generally users should assume that updates, including security
282           fixes, will not be provided.) The value is a date in the ISO 8601
283           format "YYYY-MM-DD", and specifies the first day on which support
284           is not provided.
285
286           For example, "SUPPORT_END=2001-01-01" means that the system was
287           supported until the end of the last day of the previous millennium.
288
289       LOGO=
290           A string, specifying the name of an icon as defined by
291           freedesktop.org Icon Theme Specification[6]. This can be used by
292           graphical applications to display an operating system's or
293           distributor's logo. This field is optional and may not necessarily
294           be implemented on all systems.
295
296           Examples: "LOGO=fedora-logo", "LOGO=distributor-logo-opensuse"
297
298       ANSI_COLOR=
299           A suggested presentation color when showing the OS name on the
300           console. This should be specified as string suitable for inclusion
301           in the ESC [ m ANSI/ECMA-48 escape code for setting graphical
302           rendition. This field is optional.
303
304           Examples: "ANSI_COLOR="0;31"" for red, "ANSI_COLOR="1;34"" for
305           light blue, or "ANSI_COLOR="0;38;2;60;110;180"" for Fedora blue.
306
307   Distribution-level defaults and metadata
308       DEFAULT_HOSTNAME=
309           A string specifying the hostname if hostname(5) is not present and
310           no other configuration source specifies the hostname. Must be
311           either a single DNS label (a string composed of 7-bit ASCII
312           lower-case characters and no spaces or dots, limited to the format
313           allowed for DNS domain name labels), or a sequence of such labels
314           separated by single dots that forms a valid DNS FQDN. The hostname
315           must be at most 64 characters, which is a Linux limitation (DNS
316           allows longer names).
317
318           See org.freedesktop.hostname1(5) for a description of how systemd-
319           hostnamed.service(8) determines the fallback hostname.
320
321       ARCHITECTURE=
322           A string that specifies which CPU architecture the userspace
323           binaries require. The architecture identifiers are the same as for
324           ConditionArchitecture= described in systemd.unit(5). The field is
325           optional and should only be used when just single architecture is
326           supported. It may provide redundant information when used in a GPT
327           partition with a GUID type that already encodes the architecture.
328           If this is not the case, the architecture should be specified in
329           e.g., an extension image, to prevent an incompatible host from
330           loading it.
331
332       SYSEXT_LEVEL=
333           A lower-case string (mostly numeric, no spaces or other characters
334           outside of 0–9, a–z, ".", "_" and "-") identifying the operating
335           system extensions support level, to indicate which extension images
336           are supported. See
337           /usr/lib/extension-release.d/extension-release.IMAGE, initrd[2] and
338           systemd-sysext(8)) for more information.
339
340           Examples: "SYSEXT_LEVEL=2", "SYSEXT_LEVEL=15.14".
341
342       SYSEXT_SCOPE=
343           Takes a space-separated list of one or more of the strings
344           "system", "initrd" and "portable". This field is only supported in
345           extension-release.d/ files and indicates what environments the
346           system extension is applicable to: i.e. to regular systems, to
347           initrds, or to portable service images. If unspecified,
348           "SYSEXT_SCOPE=system portable" is implied, i.e. any system
349           extension without this field is applicable to regular systems and
350           to portable service environments, but not to initrd environments.
351
352       PORTABLE_PREFIXES=
353           Takes a space-separated list of one or more valid prefix match
354           strings for the Portable Services Documentation[3] logic. This
355           field serves two purposes: it is informational, identifying
356           portable service images as such (and thus allowing them to be
357           distinguished from other OS images, such as bootable system
358           images). It is also used when a portable service image is attached:
359           the specified or implied portable service prefix is checked against
360           the list specified here, to enforce restrictions how images may be
361           attached to a system.
362
363   Notes
364       If you are using this file to determine the OS or a specific version of
365       it, use the ID and VERSION_ID fields, possibly with ID_LIKE as fallback
366       for ID. When looking for an OS identification string for presentation
367       to the user use the PRETTY_NAME field.
368
369       Note that operating system vendors may choose not to provide version
370       information, for example to accommodate for rolling releases. In this
371       case, VERSION and VERSION_ID may be unset. Applications should not rely
372       on these fields to be set.
373
374       Operating system vendors may extend the file format and introduce new
375       fields. It is highly recommended to prefix new fields with an OS
376       specific name in order to avoid name clashes. Applications reading this
377       file must ignore unknown fields.
378
379       Example: "DEBIAN_BTS="debbugs://bugs.debian.org/"".
380
381       Container and sandbox runtime managers may make the host's
382       identification data available to applications by providing the host's
383       /etc/os-release (if available, otherwise /usr/lib/os-release as a
384       fallback) as /run/host/os-release.
385

EXAMPLES

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

SEE ALSO

491       systemd(1), lsb_release(1), hostname(5), machine-id(5), machine-info(5)
492

NOTES

494        1. Announcement of /etc/os-release
495           https://0pointer.de/blog/projects/os-release
496
497        2. initrd
498           https://docs.kernel.org/admin-guide/initrd.html
499
500        3. Portable Services Documentation
501           https://systemd.io/PORTABLE_SERVICES
502
503        4. Common Platform Enumeration Specification
504           http://scap.nist.gov/specifications/cpe/
505
506        5. RFC3986 format
507           https://tools.ietf.org/html/rfc3986
508
509        6. freedesktop.org Icon Theme Specification
510           https://standards.freedesktop.org/icon-theme-spec/latest
511
512        7.
513
514                 platform.freedesktop_os_release
515           https://docs.python.org/3/library/platform.html#platform.freedesktop_os_release
516
517
518
519systemd 253                                                      OS-RELEASE(5)
Impressum