]>
Commit | Line | Data |
---|---|---|
e17fb729 | 1 | <?xml version='1.0'?> <!--*-nxml-*--> |
e17fb729 | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
12b42c76 | 3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
e17fb729 LP |
4 | |
5 | <!-- | |
572eb058 | 6 | SPDX-License-Identifier: LGPL-2.1+ |
e17fb729 LP |
7 | --> |
8 | ||
9 | <refentry id="os-release"> | |
798d3a52 ZJS |
10 | <refentryinfo> |
11 | <title>os-release</title> | |
12 | <productname>systemd</productname> | |
798d3a52 ZJS |
13 | </refentryinfo> |
14 | ||
15 | <refmeta> | |
16 | <refentrytitle>os-release</refentrytitle> | |
17 | <manvolnum>5</manvolnum> | |
18 | </refmeta> | |
19 | ||
20 | <refnamediv> | |
21 | <refname>os-release</refname> | |
22 | <refpurpose>Operating system identification</refpurpose> | |
23 | </refnamediv> | |
24 | ||
25 | <refsynopsisdiv> | |
26 | <para><filename>/etc/os-release</filename></para> | |
27 | <para><filename>/usr/lib/os-release</filename></para> | |
28 | </refsynopsisdiv> | |
29 | ||
30 | <refsect1> | |
31 | <title>Description</title> | |
32 | ||
33 | <para>The <filename>/etc/os-release</filename> and | |
34 | <filename>/usr/lib/os-release</filename> files contain operating | |
35 | system identification data.</para> | |
36 | ||
37 | <para>The basic file format of <filename>os-release</filename> is | |
38 | a newline-separated list of environment-like shell-compatible | |
39 | variable assignments. It is possible to source the configuration | |
40 | from shell scripts, however, beyond mere variable assignments, no | |
41 | shell features are supported (this means variable expansion is | |
42 | explicitly not supported), allowing applications to read the file | |
43 | without implementing a shell compatible execution engine. Variable | |
44 | assignment values must be enclosed in double or single quotes if | |
45 | they include spaces, semicolons or other special characters | |
b938cb90 | 46 | outside of A–Z, a–z, 0–9. Shell special characters ("$", quotes, |
798d3a52 ZJS |
47 | backslash, backtick) must be escaped with backslashes, following |
48 | shell style. All strings should be in UTF-8 format, and | |
49 | non-printable characters should not be used. It is not supported | |
50 | to concatenate multiple individually quoted strings. Lines | |
33ce73f6 PM |
51 | beginning with "#" shall be ignored as comments. Blank lines are |
52 | permitted and ignored.</para> | |
798d3a52 ZJS |
53 | |
54 | <para>The file <filename>/etc/os-release</filename> takes | |
55 | precedence over <filename>/usr/lib/os-release</filename>. | |
56 | Applications should check for the former, and exclusively use its | |
57 | data if it exists, and only fall back to | |
58 | <filename>/usr/lib/os-release</filename> if it is missing. | |
59 | Applications should not read data from both files at the same | |
60 | time. <filename>/usr/lib/os-release</filename> is the recommended | |
61 | place to store OS release information as part of vendor trees. | |
62 | <filename>/etc/os-release</filename> should be a relative symlink | |
63 | to <filename>/usr/lib/os-release</filename>, to provide | |
64 | compatibility with applications only looking at | |
65 | <filename>/etc</filename>. A relative symlink instead of an | |
66 | absolute symlink is necessary to avoid breaking the link in a | |
67 | chroot or initrd environment such as dracut.</para> | |
68 | ||
69 | <para><filename>os-release</filename> contains data that is | |
70 | defined by the operating system vendor and should generally not be | |
71 | changed by the administrator.</para> | |
72 | ||
73 | <para>As this file only encodes names and identifiers it should | |
74 | not be localized.</para> | |
75 | ||
76 | <para>The <filename>/etc/os-release</filename> and | |
77 | <filename>/usr/lib/os-release</filename> files might be symlinks | |
78 | to other files, but it is important that the file is available | |
79 | from earliest boot on, and hence must be located on the root file | |
80 | system.</para> | |
81 | ||
82 | <para>For a longer rationale for <filename>os-release</filename> | |
83 | please refer to the <ulink | |
b53c3c2d | 84 | url="http://0pointer.de/blog/projects/os-release">Announcement of <filename>/etc/os-release</filename></ulink>.</para> |
798d3a52 ZJS |
85 | </refsect1> |
86 | ||
87 | <refsect1> | |
88 | <title>Options</title> | |
89 | ||
90 | <para>The following OS identifications parameters may be set using | |
91 | <filename>os-release</filename>:</para> | |
92 | ||
93 | <variablelist> | |
94 | ||
95 | <varlistentry> | |
96 | <term><varname>NAME=</varname></term> | |
97 | ||
98 | <listitem><para>A string identifying the operating system, | |
99 | without a version component, and suitable for presentation to | |
100 | the user. If not set, defaults to | |
101 | <literal>NAME=Linux</literal>. Example: | |
102 | <literal>NAME=Fedora</literal> or <literal>NAME="Debian | |
103 | GNU/Linux"</literal>.</para></listitem> | |
104 | </varlistentry> | |
105 | ||
106 | <varlistentry> | |
107 | <term><varname>VERSION=</varname></term> | |
108 | ||
109 | <listitem><para>A string identifying the operating system | |
110 | version, excluding any OS name information, possibly including | |
111 | a release code name, and suitable for presentation to the | |
112 | user. This field is optional. Example: | |
113 | <literal>VERSION=17</literal> or <literal>VERSION="17 (Beefy | |
114 | Miracle)"</literal>.</para></listitem> | |
115 | </varlistentry> | |
116 | ||
117 | <varlistentry> | |
118 | <term><varname>ID=</varname></term> | |
119 | ||
120 | <listitem><para>A lower-case string (no spaces or other | |
b938cb90 | 121 | characters outside of 0–9, a–z, ".", "_" and "-") identifying |
798d3a52 ZJS |
122 | the operating system, excluding any version information and |
123 | suitable for processing by scripts or usage in generated | |
124 | filenames. If not set, defaults to | |
125 | <literal>ID=linux</literal>. Example: | |
126 | <literal>ID=fedora</literal> or | |
127 | <literal>ID=debian</literal>.</para></listitem> | |
128 | </varlistentry> | |
129 | ||
130 | <varlistentry> | |
131 | <term><varname>ID_LIKE=</varname></term> | |
132 | ||
133 | <listitem><para>A space-separated list of operating system | |
134 | identifiers in the same syntax as the <varname>ID=</varname> | |
135 | setting. It should list identifiers of operating systems that | |
136 | are closely related to the local operating system in regards | |
137 | to packaging and programming interfaces, for example listing | |
138 | one or more OS identifiers the local OS is a derivative from. | |
139 | An OS should generally only list other OS identifiers it | |
140 | itself is a derivative of, and not any OSes that are derived | |
141 | from it, though symmetric relationships are possible. Build | |
142 | scripts and similar should check this variable if they need to | |
143 | identify the local operating system and the value of | |
144 | <varname>ID=</varname> is not recognized. Operating systems | |
145 | should be listed in order of how closely the local operating | |
146 | system relates to the listed ones, starting with the closest. | |
147 | This field is optional. Example: for an operating system with | |
148 | <literal>ID=centos</literal>, an assignment of | |
149 | <literal>ID_LIKE="rhel fedora"</literal> would be appropriate. | |
150 | For an operating system with <literal>ID=ubuntu</literal>, an | |
151 | assignment of <literal>ID_LIKE=debian</literal> is | |
152 | appropriate.</para></listitem> | |
153 | </varlistentry> | |
154 | ||
646b997c BD |
155 | <varlistentry> |
156 | <term><varname>VERSION_CODENAME=</varname></term> | |
157 | ||
158 | <listitem><para> | |
159 | A lower-case string (no spaces or other characters outside of | |
160 | 0–9, a–z, ".", "_" and "-") identifying the operating system | |
161 | release code name, excluding any OS name information or | |
162 | release version, and suitable for processing by scripts or | |
163 | usage in generated filenames. This field is optional and may | |
164 | not be implemented on all systems. | |
165 | Examples: | |
166 | <literal>VERSION_CODENAME=buster</literal>, | |
167 | <literal>VERSION_CODENAME=xenial</literal> | |
168 | </para></listitem> | |
169 | </varlistentry> | |
170 | ||
798d3a52 ZJS |
171 | <varlistentry> |
172 | <term><varname>VERSION_ID=</varname></term> | |
173 | ||
174 | <listitem><para>A lower-case string (mostly numeric, no spaces | |
b938cb90 | 175 | or other characters outside of 0–9, a–z, ".", "_" and "-") |
798d3a52 ZJS |
176 | identifying the operating system version, excluding any OS |
177 | name information or release code name, and suitable for | |
178 | processing by scripts or usage in generated filenames. This | |
179 | field is optional. Example: <literal>VERSION_ID=17</literal> | |
180 | or <literal>VERSION_ID=11.04</literal>.</para></listitem> | |
181 | </varlistentry> | |
182 | ||
183 | <varlistentry> | |
184 | <term><varname>PRETTY_NAME=</varname></term> | |
185 | ||
186 | <listitem><para>A pretty operating system name in a format | |
187 | suitable for presentation to the user. May or may not contain | |
188 | a release code name or OS version of some kind, as suitable. | |
189 | If not set, defaults to | |
190 | <literal>PRETTY_NAME="Linux"</literal>. Example: | |
191 | <literal>PRETTY_NAME="Fedora 17 (Beefy | |
192 | Miracle)"</literal>.</para></listitem> | |
193 | </varlistentry> | |
194 | ||
195 | <varlistentry> | |
196 | <term><varname>ANSI_COLOR=</varname></term> | |
197 | ||
198 | <listitem><para>A suggested presentation color when showing | |
199 | the OS name on the console. This should be specified as string | |
200 | suitable for inclusion in the ESC [ m ANSI/ECMA-48 escape code | |
201 | for setting graphical rendition. This field is optional. | |
202 | Example: <literal>ANSI_COLOR="0;31"</literal> for red, or | |
203 | <literal>ANSI_COLOR="1;34"</literal> for light | |
204 | blue.</para></listitem> | |
205 | </varlistentry> | |
206 | ||
207 | <varlistentry> | |
208 | <term><varname>CPE_NAME=</varname></term> | |
209 | ||
74c1d3e7 DH |
210 | <listitem><para>A CPE name for the operating system, in URI |
211 | binding syntax, following the | |
212 | <ulink url="http://scap.nist.gov/specifications/cpe/">Common | |
798d3a52 | 213 | Platform Enumeration Specification</ulink> as proposed by the |
74c1d3e7 | 214 | NIST. This field is optional. Example: |
798d3a52 ZJS |
215 | <literal>CPE_NAME="cpe:/o:fedoraproject:fedora:17"</literal> |
216 | </para></listitem> | |
217 | </varlistentry> | |
218 | ||
219 | <varlistentry> | |
220 | <term><varname>HOME_URL=</varname></term> | |
221 | <term><varname>SUPPORT_URL=</varname></term> | |
222 | <term><varname>BUG_REPORT_URL=</varname></term> | |
223 | <term><varname>PRIVACY_POLICY_URL=</varname></term> | |
224 | ||
225 | <listitem><para>Links to resources on the Internet related the | |
226 | operating system. <varname>HOME_URL=</varname> should refer to | |
227 | the homepage of the operating system, or alternatively some | |
228 | homepage of the specific version of the operating system. | |
229 | <varname>SUPPORT_URL=</varname> should refer to the main | |
230 | support page for the operating system, if there is any. This | |
231 | is primarily intended for operating systems which vendors | |
232 | provide support for. <varname>BUG_REPORT_URL=</varname> should | |
233 | refer to the main bug reporting page for the operating system, | |
234 | if there is any. This is primarily intended for operating | |
235 | systems that rely on community QA. | |
236 | <varname>PRIVACY_POLICY_URL=</varname> should refer to the | |
237 | main privacy policy page for the operation system, if there is | |
238 | any. These settings are optional, and providing only some of | |
239 | these settings is common. These URLs are intended to be | |
240 | exposed in "About this system" UIs behind links with captions | |
241 | such as "About this Operating System", "Obtain Support", | |
242 | "Report a Bug", or "Privacy Policy". The values should be in | |
243 | <ulink url="https://tools.ietf.org/html/rfc3986">RFC3986 | |
244 | format</ulink>, and should be <literal>http:</literal> or | |
245 | <literal>https:</literal> URLs, and possibly | |
246 | <literal>mailto:</literal> or <literal>tel:</literal>. Only | |
247 | one URL shall be listed in each setting. If multiple resources | |
248 | need to be referenced, it is recommended to provide an online | |
249 | landing page linking all available resources. Examples: | |
250 | <literal>HOME_URL="https://fedoraproject.org/"</literal> and | |
251 | <literal>BUG_REPORT_URL="https://bugzilla.redhat.com/"</literal></para></listitem> | |
252 | </varlistentry> | |
253 | ||
254 | <varlistentry> | |
255 | <term><varname>BUILD_ID=</varname></term> | |
256 | ||
257 | <listitem><para>A string uniquely identifying the system image | |
258 | used as the origin for a distribution (it is not updated with | |
259 | system updates). The field can be identical between different | |
260 | VERSION_IDs as BUILD_ID is an only a unique identifier to a | |
261 | specific version. Distributions that release each update as a | |
262 | new version would only need to use VERSION_ID as each build is | |
263 | already distinct based on the VERSION_ID. This field is | |
264 | optional. Example: <literal>BUILD_ID="2013-03-20.3"</literal> | |
265 | or <literal>BUILD_ID=201303203</literal>. | |
266 | ||
267 | </para></listitem> | |
268 | </varlistentry> | |
269 | ||
be7d0048 SG |
270 | <varlistentry> |
271 | <term><varname>VARIANT=</varname></term> | |
272 | ||
273 | <listitem><para> | |
274 | A string identifying a specific variant or edition of the | |
275 | operating system suitable for presentation to the user. This | |
276 | field may be used to inform the user that the configuration of | |
277 | this system is subject to a specific divergent set of rules or | |
278 | default configuration settings. This field is optional and may | |
279 | not be implemented on all systems. | |
280 | Examples: | |
281 | <literal>VARIANT="Server Edition"</literal>, | |
282 | <literal>VARIANT="Smart Refrigerator Edition"</literal> | |
283 | Note: this field is for display purposes only. The | |
284 | <varname>VARIANT_ID</varname> field should be used for making | |
285 | programmatic decisions. | |
286 | </para></listitem> | |
287 | </varlistentry> | |
288 | ||
289 | <varlistentry> | |
290 | <term><varname>VARIANT_ID=</varname></term> | |
291 | ||
292 | <listitem><para> | |
293 | A lower-case string (no spaces or other characters outside of | |
b938cb90 | 294 | 0–9, a–z, ".", "_" and "-"), identifying a specific variant or |
be7d0048 SG |
295 | edition of the operating system. This may be interpreted by |
296 | other packages in order to determine a divergent default | |
297 | configuration. This field is optional and may not be | |
298 | implemented on all systems. | |
299 | Examples: | |
300 | <literal>VARIANT_ID=server</literal>, | |
301 | <literal>VARIANT_ID=embedded</literal> | |
302 | </para></listitem> | |
303 | </varlistentry> | |
304 | ||
798d3a52 ZJS |
305 | </variablelist> |
306 | ||
307 | <para>If you are reading this file from C code or a shell script | |
308 | to determine the OS or a specific version of it, use the | |
309 | <varname>ID</varname> and <varname>VERSION_ID</varname> fields, | |
310 | possibly with <varname>ID_LIKE</varname> as fallback for | |
311 | <varname>ID</varname>. When looking for an OS identification | |
312 | string for presentation to the user use the | |
313 | <varname>PRETTY_NAME</varname> field.</para> | |
314 | ||
315 | <para>Note that operating system vendors may choose not to provide | |
316 | version information, for example to accommodate for rolling | |
317 | releases. In this case, <varname>VERSION</varname> and | |
318 | <varname>VERSION_ID</varname> may be unset. Applications should | |
319 | not rely on these fields to be set.</para> | |
320 | ||
321 | <para>Operating system vendors may extend the file | |
322 | format and introduce new fields. It is highly | |
323 | recommended to prefix new fields with an OS specific | |
324 | name in order to avoid name clashes. Applications | |
325 | reading this file must ignore unknown fields. Example: | |
326 | <literal>DEBIAN_BTS="debbugs://bugs.debian.org/"</literal></para> | |
327 | </refsect1> | |
328 | ||
329 | <refsect1> | |
330 | <title>Example</title> | |
331 | ||
332 | <programlisting>NAME=Fedora | |
f8045772 | 333 | VERSION="17 (Beefy Miracle)" |
e17fb729 | 334 | ID=fedora |
88ce7229 | 335 | VERSION_ID=17 |
f8045772 LP |
336 | PRETTY_NAME="Fedora 17 (Beefy Miracle)" |
337 | ANSI_COLOR="0;34" | |
62ca938d LP |
338 | CPE_NAME="cpe:/o:fedoraproject:fedora:17" |
339 | HOME_URL="https://fedoraproject.org/" | |
340 | BUG_REPORT_URL="https://bugzilla.redhat.com/"</programlisting> | |
798d3a52 ZJS |
341 | </refsect1> |
342 | ||
343 | <refsect1> | |
344 | <title>See Also</title> | |
345 | <para> | |
346 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
3ba3a79d | 347 | <citerefentry project='die-net'><refentrytitle>lsb_release</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
798d3a52 ZJS |
348 | <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
349 | <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
350 | <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
351 | </para> | |
352 | </refsect1> | |
e17fb729 LP |
353 | |
354 | </refentry> |