]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/file-hierarchy.xml
man: add version info
[thirdparty/systemd.git] / man / file-hierarchy.xml
CommitLineData
9546c6ed 1<?xml version='1.0'?> <!--*-nxml-*-->
3a54a157 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
12b42c76 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
db9ecf05 4<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
9546c6ed 5
4623eecb 6<refentry id="file-hierarchy" xmlns:xi="http://www.w3.org/2001/XInclude">
9546c6ed 7
798d3a52
ZJS
8 <refentryinfo>
9 <title>file-hierarchy</title>
10 <productname>systemd</productname>
798d3a52
ZJS
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>file-hierarchy</refentrytitle>
15 <manvolnum>7</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>file-hierarchy</refname>
20 <refpurpose>File system hierarchy overview</refpurpose>
21 </refnamediv>
22
23 <refsect1>
24 <title>Description</title>
25
26 <para>Operating systems using the
03f2b38e
LP
27 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> system and service
28 manager are organized based on a file system hierarchy inspired by UNIX, more specifically the hierarchy described
29 in the <ulink url="http://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html">File System Hierarchy</ulink>
30 specification and <citerefentry
31 project='man-pages'><refentrytitle>hier</refentrytitle><manvolnum>7</manvolnum></citerefentry>, with various
32 extensions, partially documented in the <ulink
41d6f3bf 33 url="https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG Base Directory
a25d9395 34 Specification</ulink> and <ulink url="https://www.freedesktop.org/wiki/Software/xdg-user-dirs">XDG User
03f2b38e
LP
35 Directories</ulink>. This manual page describes a more generalized, though minimal and modernized subset of these
36 specifications that defines more strictly the suggestions and restrictions systemd makes on the file system
798d3a52
ZJS
37 hierarchy.</para>
38
cd72d204 39 <para>Many of the paths described here can be queried
798d3a52
ZJS
40 with the
41 <citerefentry><refentrytitle>systemd-path</refentrytitle><manvolnum>1</manvolnum></citerefentry>
42 tool.</para>
43 </refsect1>
44
45 <refsect1>
46 <title>General Structure</title>
47
48 <variablelist>
49 <varlistentry>
50 <term><filename>/</filename></term>
51 <listitem><para>The file system root. Usually writable, but
52 this is not required. Possibly a temporary file system
53 (<literal>tmpfs</literal>). Not shared with other hosts
ec07c3c8
AK
54 (unless read-only). </para>
55
56 <xi:include href="version-info.xml" xpointer="v215"/></listitem>
798d3a52
ZJS
57 </varlistentry>
58
59 <varlistentry>
5eb5f352 60 <term><filename>/boot/</filename></term>
798d3a52 61 <listitem><para>The boot partition used for bringing up the
b938cb90 62 system. On EFI systems, this is possibly the EFI System
1dc7ca99 63 Partition (ESP), also see
59512f21 64 <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
798d3a52
ZJS
65 This directory is usually strictly local to the host, and
66 should be considered read-only, except when a new kernel or
67 boot loader is installed. This directory only exists on
68 systems that run on physical or emulated hardware that
ec07c3c8
AK
69 requires boot loaders.</para>
70
71 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
72 </varlistentry>
73
1dc7ca99
LP
74 <varlistentry>
75 <term><filename>/efi/</filename></term>
76 <listitem><para>If the boot partition <filename>/boot/</filename> is maintained separately from the EFI System
77 Partition (ESP), the latter is mounted here. Tools that need to operate on the EFI system partition should look
78 for it at this mount point first, and fall back to <filename>/boot/</filename> — if the former doesn't qualify
79 (for example if it is not a mount point or does not have the correct file system type
ec07c3c8
AK
80 <constant>MSDOS_SUPER_MAGIC</constant>).</para>
81
82 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
1dc7ca99
LP
83 </varlistentry>
84
798d3a52 85 <varlistentry>
5eb5f352 86 <term><filename>/etc/</filename></term>
798d3a52
ZJS
87 <listitem><para>System-specific configuration. This directory
88 may or may not be read-only. Frequently, this directory is
89 pre-populated with vendor-supplied configuration files, but
90 applications should not make assumptions about this directory
91 being fully populated or populated at all, and should fall
92 back to defaults if configuration is
ec07c3c8
AK
93 missing.</para>
94
95 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
96 </varlistentry>
97
98 <varlistentry>
5eb5f352 99 <term><filename>/home/</filename></term>
798d3a52
ZJS
100 <listitem><para>The location for normal user's home
101 directories. Possibly shared with other systems, and never
102 read-only. This directory should only be used for normal
103 users, never for system users. This directory and possibly the
104 directories contained within it might only become available or
105 writable in late boot or even only after user authentication.
106 This directory might be placed on limited-functionality
107 network file systems, hence applications should not assume the
108 full set of file API is available on this directory.
109 Applications should generally not reference this directory
110 directly, but via the per-user <varname>$HOME</varname>
111 environment variable, or via the home directory field of the
ec07c3c8
AK
112 user database.</para>
113
114 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
115 </varlistentry>
116
117 <varlistentry>
5eb5f352 118 <term><filename>/root/</filename></term>
798d3a52
ZJS
119 <listitem><para>The home directory of the root user. The root
120 user's home directory is located outside of
5eb5f352
LP
121 <filename>/home/</filename> in order to make sure the root user
122 may log in even without <filename>/home/</filename> being
ec07c3c8
AK
123 available and mounted.</para>
124
125 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
126 </varlistentry>
127
128 <varlistentry>
5eb5f352 129 <term><filename>/srv/</filename></term>
798d3a52
ZJS
130 <listitem><para>The place to store general server payload,
131 managed by the administrator. No restrictions are made how
132 this directory is organized internally. Generally writable,
133 and possibly shared among systems. This directory might become
134 available or writable only very late during
ec07c3c8
AK
135 boot.</para>
136
137 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
138 </varlistentry>
139
140 <varlistentry>
5eb5f352 141 <term><filename>/tmp/</filename></term>
25f77a4b
LP
142 <listitem><para>The place for small temporary files. This directory is usually mounted as a
143 <literal>tmpfs</literal> instance, and should hence not be used for larger files. (Use
422128b4
ZJS
144 <filename>/var/tmp/</filename> for larger files.) This directory is usually flushed at boot-up. Also,
145 files that are not accessed within a certain time may be automatically deleted.</para>
146
147 <para>If applications find the environment variable <varname>$TMPDIR</varname> set, they should use
148 the directory specified in it instead of <filename>/tmp/</filename> (see <citerefentry
25f77a4b 149 project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry> and
798d3a52 150 <ulink url="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03">IEEE
422128b4
ZJS
151 Std 1003.1</ulink> for details).</para>
152
153 <para>Since <filename>/tmp/</filename> is accessible to other users of the system, it is essential
154 that files and subdirectories under this directory are only created with <citerefentry
155 project='man-pages'><refentrytitle>mkstemp</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
156 <citerefentry
157 project='man-pages'><refentrytitle>mkdtemp</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
158 and similar calls. For more details, see <ulink url="https://systemd.io/TEMPORARY_DIRECTORIES">Using
159 /tmp/ and /var/tmp/ Safely</ulink>.</para>
ec07c3c8
AK
160
161 <xi:include href="version-info.xml" xpointer="v239"/>
422128b4 162 </listitem>
798d3a52
ZJS
163 </varlistentry>
164
165 </variablelist>
166 </refsect1>
167
168 <refsect1>
169 <title>Runtime Data</title>
170
171 <variablelist>
172 <varlistentry>
5eb5f352 173 <term><filename>/run/</filename></term>
e5f093bf
ZJS
174 <listitem><para>A <literal>tmpfs</literal> file system for system packages to place runtime data,
175 socket files, and similar. This directory is flushed on boot, and generally writable for privileged
ec07c3c8
AK
176 programs only. Always writable.</para>
177
178 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
179 </varlistentry>
180
181 <varlistentry>
5eb5f352 182 <term><filename>/run/log/</filename></term>
798d3a52
ZJS
183 <listitem><para>Runtime system logs. System components may
184 place private logs in this directory. Always writable, even
5eb5f352 185 when <filename>/var/log/</filename> might not be accessible
ec07c3c8
AK
186 yet.</para>
187
188 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
189 </varlistentry>
190
191 <varlistentry>
5eb5f352 192 <term><filename>/run/user/</filename></term>
798d3a52
ZJS
193 <listitem><para>Contains per-user runtime directories, each
194 usually individually mounted <literal>tmpfs</literal>
195 instances. Always writable, flushed at each reboot and when
196 the user logs out. User code should not reference this
197 directory directly, but via the
198 <varname>$XDG_RUNTIME_DIR</varname> environment variable, as
199 documented in the <ulink
41d6f3bf 200 url="https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG
ec07c3c8
AK
201 Base Directory Specification</ulink>.</para>
202
203 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
204 </varlistentry>
205 </variablelist>
206 </refsect1>
207
208 <refsect1>
209 <title>Vendor-supplied Operating System Resources</title>
210
211 <variablelist>
212
213 <varlistentry>
5eb5f352 214 <term><filename>/usr/</filename></term>
798d3a52
ZJS
215 <listitem><para>Vendor-supplied operating system resources.
216 Usually read-only, but this is not required. Possibly shared
217 between multiple hosts. This directory should not be modified
218 by the administrator, except when installing or removing
ec07c3c8
AK
219 vendor-supplied packages.</para>
220
221 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
222 </varlistentry>
223
224 <varlistentry>
5eb5f352 225 <term><filename>/usr/bin/</filename></term>
b938cb90 226 <listitem><para>Binaries and executables for user commands
798d3a52
ZJS
227 that shall appear in the <varname>$PATH</varname> search path.
228 It is recommended not to place binaries in this directory that
229 are not useful for invocation from a shell (such as daemon
230 binaries); these should be placed in a subdirectory of
ec07c3c8
AK
231 <filename>/usr/lib/</filename> instead.</para>
232
233 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
234 </varlistentry>
235
236 <varlistentry>
5eb5f352 237 <term><filename>/usr/include/</filename></term>
798d3a52 238 <listitem><para>C and C++ API header files of system
ec07c3c8
AK
239 libraries.</para>
240
241 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
242 </varlistentry>
243
244 <varlistentry>
5eb5f352 245 <term><filename>/usr/lib/</filename></term>
798d3a52
ZJS
246 <listitem><para>Static, private vendor data that is compatible
247 with all architectures (though not necessarily
248 architecture-independent). Note that this includes internal
249 executables or other binaries that are not regularly invoked
250 from a shell. Such binaries may be for any architecture
251 supported by the system. Do not place public libraries in this
252 directory, use <varname>$libdir</varname> (see below),
ec07c3c8
AK
253 instead.</para>
254
255 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
256 </varlistentry>
257
258 <varlistentry>
5eb5f352 259 <term><filename>/usr/lib/<replaceable>arch-id</replaceable>/</filename></term>
a8eaaee7 260 <listitem><para>Location for placing dynamic libraries into, also
798d3a52
ZJS
261 called <varname>$libdir</varname>. The architecture identifier
262 to use is defined on <ulink
263 url="https://wiki.debian.org/Multiarch/Tuples">Multiarch
264 Architecture Specifiers (Tuples)</ulink> list. Legacy
265 locations of <varname>$libdir</varname> are
5eb5f352
LP
266 <filename>/usr/lib/</filename>,
267 <filename>/usr/lib64/</filename>. This directory should not be
798d3a52
ZJS
268 used for package-specific data, unless this data is
269 architecture-dependent, too. To query
270 <varname>$libdir</varname> for the primary architecture of the
ffd86446 271 system, invoke:
ec07c3c8
AK
272 <programlisting># systemd-path system-library-arch</programlisting></para>
273
274 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
275
276 </varlistentry>
277
278 <varlistentry>
5eb5f352 279 <term><filename>/usr/share/</filename></term>
798d3a52
ZJS
280 <listitem><para>Resources shared between multiple packages,
281 such as documentation, man pages, time zone information, fonts
282 and other resources. Usually, the precise location and format
283 of files stored below this directory is subject to
ec07c3c8
AK
284 specifications that ensure interoperability.</para>
285
286 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
287 </varlistentry>
288
289 <varlistentry>
5eb5f352 290 <term><filename>/usr/share/doc/</filename></term>
798d3a52 291 <listitem><para>Documentation for the operating system or
ec07c3c8
AK
292 system packages.</para>
293
294 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
295 </varlistentry>
296
297 <varlistentry>
5eb5f352 298 <term><filename>/usr/share/factory/etc/</filename></term>
798d3a52
ZJS
299 <listitem><para>Repository for vendor-supplied default
300 configuration files. This directory should be populated with
301 pristine vendor versions of all configuration files that may
5eb5f352 302 be placed in <filename>/etc/</filename>. This is useful to
798d3a52
ZJS
303 compare the local configuration of a system with vendor
304 defaults and to populate the local configuration with
ec07c3c8
AK
305 defaults.</para>
306
307 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
308 </varlistentry>
309
310 <varlistentry>
5eb5f352 311 <term><filename>/usr/share/factory/var/</filename></term>
798d3a52
ZJS
312
313 <listitem><para>Similar to
5eb5f352 314 <filename>/usr/share/factory/etc/</filename>, but for vendor
798d3a52 315 versions of files in the variable, persistent data directory
ec07c3c8
AK
316 <filename>/var/</filename>.</para>
317
318 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
319
320 </varlistentry>
321 </variablelist>
322 </refsect1>
323
324 <refsect1>
325 <title>Persistent Variable System Data</title>
326
327 <variablelist>
328 <varlistentry>
5eb5f352 329 <term><filename>/var/</filename></term>
e5f093bf
ZJS
330 <listitem><para>Persistent, variable system data. Writable during normal system operation. This
331 directory might be pre-populated with vendor-supplied data, but applications should be able to
332 reconstruct necessary files and directories in this subhierarchy should they be missing, as the
333 system might start up without this directory being populated. Persistency is recommended, but
334 optional, to support ephemeral systems. This directory might become available or writable only very
335 late during boot. Components that are required to operate during early boot hence shall not
ec07c3c8
AK
336 unconditionally rely on this directory.</para>
337
338 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
339 </varlistentry>
340
341 <varlistentry>
5eb5f352 342 <term><filename>/var/cache/</filename></term>
798d3a52
ZJS
343 <listitem><para>Persistent system cache data. System
344 components may place non-essential data in this directory.
345 Flushing this directory should have no effect on operation of
346 programs, except for increased runtimes necessary to rebuild
ec07c3c8
AK
347 these caches.</para>
348
349 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
350 </varlistentry>
351
352 <varlistentry>
5eb5f352 353 <term><filename>/var/lib/</filename></term>
798d3a52 354 <listitem><para>Persistent system data. System components may
ec07c3c8
AK
355 place private data in this directory.</para>
356
357 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
358 </varlistentry>
359
360 <varlistentry>
5eb5f352 361 <term><filename>/var/log/</filename></term>
798d3a52
ZJS
362 <listitem><para>Persistent system logs. System components may
363 place private logs in this directory, though it is recommended
364 to do most logging via the
365 <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
366 and
367 <citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>3</manvolnum></citerefentry>
ec07c3c8
AK
368 calls.</para>
369
370 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
371 </varlistentry>
372
373 <varlistentry>
5eb5f352 374 <term><filename>/var/spool/</filename></term>
798d3a52 375 <listitem><para>Persistent system spool data, such as printer
ec07c3c8
AK
376 or mail queues.</para>
377
378 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
379 </varlistentry>
380
381 <varlistentry>
5eb5f352 382 <term><filename>/var/tmp/</filename></term>
25f77a4b
LP
383 <listitem><para>The place for larger and persistent temporary files. In contrast to
384 <filename>/tmp/</filename>, this directory is usually mounted from a persistent physical file system
422128b4
ZJS
385 and can thus accept larger files. (Use <filename>/tmp/</filename> for small ephemeral files.) This
386 directory is generally not flushed at boot-up, but time-based cleanup of files that have not been
387 accessed for a certain time is applied.</para>
388
389 <para>If applications find the environment variable <varname>$TMPDIR</varname> set, they should use
390 the directory specified in it instead of <filename>/var/tmp/</filename> (see <citerefentry
391 project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
392 details).</para>
393
394 <para>The same security restrictions as with <filename>/tmp/</filename> apply: <citerefentry
25f77a4b
LP
395 project='man-pages'><refentrytitle>mkstemp</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
396 <citerefentry
422128b4
ZJS
397 project='man-pages'><refentrytitle>mkdtemp</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
398 and similar calls should be used. For further details about this directory, see <ulink
399 url="https://systemd.io/TEMPORARY_DIRECTORIES">Using /tmp/ and /var/tmp/ Safely</ulink>.</para>
ec07c3c8
AK
400
401 <xi:include href="version-info.xml" xpointer="v239"/>
422128b4 402 </listitem>
798d3a52
ZJS
403 </varlistentry>
404
405 </variablelist>
406 </refsect1>
407
408 <refsect1>
409 <title>Virtual Kernel and API File Systems</title>
410
411 <variablelist>
412 <varlistentry>
5eb5f352 413 <term><filename>/dev/</filename></term>
b938cb90 414 <listitem><para>The root directory for device nodes. Usually,
798d3a52
ZJS
415 this directory is mounted as a <literal>devtmpfs</literal>
416 instance, but might be of a different type in
417 sandboxed/containerized setups. This directory is managed
418 jointly by the kernel and
419 <citerefentry><refentrytitle>systemd-udevd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
420 and should not be written to by other components. A number of
421 special purpose virtual file systems might be mounted below
ec07c3c8
AK
422 this directory.</para>
423
424 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
425 </varlistentry>
426
427 <varlistentry>
5eb5f352 428 <term><filename>/dev/shm/</filename></term>
798d3a52
ZJS
429 <listitem><para>Place for POSIX shared memory segments, as
430 created via
3ba3a79d 431 <citerefentry project='die-net'><refentrytitle>shm_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
798d3a52
ZJS
432 This directory is flushed on boot, and is a
433 <literal>tmpfs</literal> file system. Since all users have
434 write access to this directory, special care should be taken
435 to avoid name clashes and vulnerabilities. For normal users,
436 shared memory segments in this directory are usually deleted
b938cb90 437 when the user logs out. Usually, it is a better idea to use
5eb5f352 438 memory mapped files in <filename>/run/</filename> (for system
798d3a52 439 programs) or <varname>$XDG_RUNTIME_DIR</varname> (for user
a8eaaee7 440 programs) instead of POSIX shared memory segments, since these
798d3a52 441 directories are not world-writable and hence not vulnerable to
ec07c3c8
AK
442 security-sensitive name clashes.</para>
443
444 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
445 </varlistentry>
446
447 <varlistentry>
5eb5f352 448 <term><filename>/proc/</filename></term>
798d3a52
ZJS
449 <listitem><para>A virtual kernel file system exposing the
450 process list and other functionality. This file system is
451 mostly an API to interface with the kernel and not a place
452 where normal files may be stored. For details, see
453 <citerefentry project='man-pages'><refentrytitle>proc</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
454 A number of special purpose virtual file systems might be
ec07c3c8
AK
455 mounted below this directory.</para>
456
457 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
458 </varlistentry>
459
460 <varlistentry>
5eb5f352
LP
461 <term><filename>/proc/sys/</filename></term>
462 <listitem><para>A hierarchy below <filename>/proc/</filename>
798d3a52
ZJS
463 that exposes a number of kernel tunables. The primary way to
464 configure the settings in this API file tree is via
465 <citerefentry><refentrytitle>sysctl.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
b938cb90 466 files. In sandboxed/containerized setups, this directory is
ec07c3c8
AK
467 generally mounted read-only.</para>
468
469 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
470 </varlistentry>
471
472 <varlistentry>
5eb5f352 473 <term><filename>/sys/</filename></term>
798d3a52
ZJS
474 <listitem><para>A virtual kernel file system exposing
475 discovered devices and other functionality. This file system
476 is mostly an API to interface with the kernel and not a place
477 where normal files may be stored. In sandboxed/containerized
b938cb90 478 setups, this directory is generally mounted read-only. A number
798d3a52 479 of special purpose virtual file systems might be mounted below
ec07c3c8
AK
480 this directory.</para>
481
482 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
483 </varlistentry>
484
c8aeb9d6
JT
485 <varlistentry>
486 <term><filename>/sys/fs/cgroup/</filename></term>
487 <listitem><para>A virtual kernel file system exposing process
488 control groups (cgroups). This file system is an API to interface
489 with the kernel and not a place where normal files may be stored. On
490 current systems running in the default "unified" mode,
491 this directory serves as the mount point for the
492 <literal>cgroup2</literal> filesystem, which provides a unified
493 cgroup hierarchy for all resource controllers. On systems with
494 non-default configurations, this directory may instead be a tmpfs
495 filesystem containing mount points for various
496 <literal>cgroup</literal> (v1) resource controllers; in such
497 configurations, if <literal>cgroup2</literal> is mounted it will be
498 mounted on <filename>/sys/fs/cgroup/unified/</filename>, but
499 cgroup2 will not have resource controllers attached. In
500 sandboxed/containerized setups, this directory may either not exist or
501 may include a subset of functionality.
ec07c3c8
AK
502 </para>
503
504 <xi:include href="version-info.xml" xpointer="v251"/></listitem>
c8aeb9d6 505 </varlistentry>
798d3a52
ZJS
506 </variablelist>
507 </refsect1>
508
509 <refsect1>
510 <title>Compatibility Symlinks</title>
511
512 <variablelist>
513 <varlistentry>
5eb5f352
LP
514 <term><filename>/bin/</filename></term>
515 <term><filename>/sbin/</filename></term>
516 <term><filename>/usr/sbin/</filename></term>
798d3a52
ZJS
517
518 <listitem><para>These compatibility symlinks point to
5eb5f352 519 <filename>/usr/bin/</filename>, ensuring that scripts and
798d3a52 520 binaries referencing these legacy paths correctly find their
ec07c3c8
AK
521 binaries.</para>
522
523 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
524 </varlistentry>
525
526 <varlistentry>
5eb5f352 527 <term><filename>/lib/</filename></term>
798d3a52
ZJS
528
529 <listitem><para>This compatibility symlink points to
5eb5f352 530 <filename>/usr/lib/</filename>, ensuring that programs
798d3a52 531 referencing this legacy path correctly find their
ec07c3c8
AK
532 resources.</para>
533
534 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
535 </varlistentry>
536
537 <varlistentry>
5eb5f352 538 <term><filename>/lib64/</filename></term>
798d3a52 539
b938cb90 540 <listitem><para>On some architecture ABIs, this compatibility
798d3a52
ZJS
541 symlink points to <varname>$libdir</varname>, ensuring that
542 binaries referencing this legacy path correctly find their
543 dynamic loader. This symlink only exists on architectures
544 whose ABI places the dynamic loader in this
ec07c3c8
AK
545 path.</para>
546
547 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
548 </varlistentry>
549
550 <varlistentry>
5eb5f352 551 <term><filename>/var/run/</filename></term>
798d3a52
ZJS
552
553 <listitem><para>This compatibility symlink points to
5eb5f352 554 <filename>/run/</filename>, ensuring that programs referencing
798d3a52 555 this legacy path correctly find their runtime
ec07c3c8
AK
556 data.</para>
557
558 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
559 </varlistentry>
560
561 </variablelist>
562 </refsect1>
563
564 <refsect1>
565 <title>Home Directory</title>
566
567 <para>User applications may want to place files and directories in
568 the user's home directory. They should follow the following basic
569 structure. Note that some of these directories are also
570 standardized (though more weakly) by the <ulink
41d6f3bf 571 url="https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG
798d3a52
ZJS
572 Base Directory Specification</ulink>. Additional locations for
573 high-level user resources are defined by <ulink
a25d9395 574 url="https://www.freedesktop.org/wiki/Software/xdg-user-dirs">xdg-user-dirs</ulink>.</para>
798d3a52
ZJS
575
576 <variablelist>
577 <varlistentry>
5eb5f352 578 <term><filename>~/.cache/</filename></term>
798d3a52 579
fa1d3482
LP
580 <listitem><para>Persistent user cache data. User programs may place non-essential data in this
581 directory. Flushing this directory should have no effect on operation of programs, except for
582 increased runtimes necessary to rebuild these caches. If an application finds
583 <varname>$XDG_CACHE_HOME</varname> set, it should use the directory specified in it instead of this
ec07c3c8
AK
584 directory.</para>
585
586 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
587 </varlistentry>
588
589 <varlistentry>
5eb5f352 590 <term><filename>~/.config/</filename></term>
798d3a52 591
b4d6bc63
FY
592 <listitem><para>Application configuration. When a new user is created, this directory will be empty
593 or not exist at all. Applications should fall back to defaults should their configuration in this
594 directory be missing. If an application finds <varname>$XDG_CONFIG_HOME</varname> set, it should use
ec07c3c8
AK
595 the directory specified in it instead of this directory.</para>
596
597 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
598 </varlistentry>
599
600 <varlistentry>
5eb5f352 601 <term><filename>~/.local/bin/</filename></term>
798d3a52 602
fa1d3482
LP
603 <listitem><para>Executables that shall appear in the user's <varname>$PATH</varname> search path. It
604 is recommended not to place executables in this directory that are not useful for invocation from a
605 shell; these should be placed in a subdirectory of <filename>~/.local/lib/</filename> instead. Care
606 should be taken when placing architecture-dependent binaries in this place, which might be
607 problematic if the home directory is shared between multiple hosts with different
ec07c3c8
AK
608 architectures.</para>
609
610 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
611 </varlistentry>
612
613 <varlistentry>
5eb5f352 614 <term><filename>~/.local/lib/</filename></term>
798d3a52 615
fa1d3482 616 <listitem><para>Static, private vendor data that is compatible with all
ec07c3c8
AK
617 architectures.</para>
618
619 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
620 </varlistentry>
621
622 <varlistentry>
5eb5f352 623 <term><filename>~/.local/lib/<replaceable>arch-id</replaceable>/</filename></term>
798d3a52 624
fa1d3482
LP
625 <listitem><para>Location for placing public dynamic libraries. The architecture identifier to use is
626 defined on <ulink url="https://wiki.debian.org/Multiarch/Tuples">Multiarch Architecture Specifiers
ec07c3c8
AK
627 (Tuples)</ulink> list.</para>
628
629 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
630 </varlistentry>
631
632 <varlistentry>
5eb5f352 633 <term><filename>~/.local/share/</filename></term>
798d3a52 634
fa1d3482
LP
635 <listitem><para>Resources shared between multiple packages, such as fonts or artwork. Usually, the
636 precise location and format of files stored below this directory is subject to specifications that
637 ensure interoperability. If an application finds <varname>$XDG_DATA_HOME</varname> set, it should use
ec07c3c8
AK
638 the directory specified in it instead of this directory.</para>
639
640 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
798d3a52
ZJS
641 </varlistentry>
642
b4d6bc63
FY
643 <varlistentry>
644 <term><filename>~/.local/state/</filename></term>
645
646 <listitem><para>Application state. When a new user is created, this directory will be empty or not
647 exist at all. Applications should fall back to defaults should their state in this directory be
648 missing. If an application finds <varname>$XDG_STATE_HOME</varname> set, it should use the directory
ec07c3c8
AK
649 specified in it instead of this directory.</para>
650
651 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
b4d6bc63
FY
652 </varlistentry>
653
798d3a52
ZJS
654 </variablelist>
655 </refsect1>
656
798d3a52 657 <refsect1>
e5f093bf
ZJS
658 <title>Write Access</title>
659
660 <refsect2>
661 <title>Unprivileged Write Access</title>
662
663 <para>Unprivileged processes generally lack write access to most of the hierarchy.</para>
664
665 <para>The exceptions for normal users are
666 <filename>/tmp/</filename>,
667 <filename>/var/tmp/</filename>,
668 <filename>/dev/shm/</filename>, as well as the home directory
669 <varname>$HOME</varname> (usually found below
670 <filename>/home/</filename>) and the runtime directory
671 <varname>$XDG_RUNTIME_DIR</varname> (found below
672 <filename>/run/user/</filename>) of the user, which are all
673 writable.</para>
674
675 <para>For unprivileged system processes, only
676 <filename>/tmp/</filename>,
677 <filename>/var/tmp/</filename> and
678 <filename>/dev/shm/</filename> are writable. If an
679 unprivileged system process needs a private writable directory in
680 <filename>/var/</filename> or <filename>/run/</filename>, it is
681 recommended to either create it before dropping privileges in the
682 daemon code, to create it via
683 <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
684 fragments during boot, or via the
685 <varname>StateDirectory=</varname> and <varname>RuntimeDirectory=</varname>
686 directives of service units (see
687 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
688 for details).</para>
689
690 <para><filename>/tmp/</filename>, <filename>/var/tmp/</filename> and <filename>/dev/shm/</filename>
691 should be mounted <option>nosuid</option> and <option>nodev</option>, which means that set-user-id mode
692 and character or block special devices are not interpreted on those file systems. In general it is not
693 possible to mount them <option>noexec</option>, because various programs use those directories for
694 dynamically generated or optimized code, and with that flag those use cases would break. Using this
695 flag is OK on special-purpose installations or systems where all software that may be installed is
696 known and doesn't require such functionality. See the discussion of
697 <option>nosuid</option>/<option>nodev</option>/<option>noexec</option> in <citerefentry
698 project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> and
699 <constant>PROT_EXEC</constant> in <citerefentry
700 project='man-pages'><refentrytitle>mmap</refentrytitle><manvolnum>2</manvolnum></citerefentry>.
701 </para>
702 </refsect2>
703
704 <refsect2>
705 <title>Lack of Write Access on Read-Only Systems and during System Recovery</title>
706
707 <para>As noted above, some systems operate with the <filename>/usr</filename> and
708 <filename>/etc</filename> hierarchies mounted read-only, possibly only allowing write access during
709 package upgrades. Other part of the hierarchy are generally mounted read-write (in particular
710 <filename>/var</filename> and <filename>/var/tmp</filename>), but may be read-only when the kernel
711 remounts the file system read-only in response to errors, or when the system is booted read-only for
712 recovery purposes. To the extent reasonable, applications should be prepared to execute without write
713 access, so that for example, failure to save non-essential data to <filename>/var/cache/</filename> or
714 failure to create a custom log file under <filename>/var/log</filename> does not prevent the
715 application from running.</para>
716
717 <para>The <filename>/run/</filename> directory is available since the earliest boot and is always
718 writable. It should be used for any runtime data and sockets, so that write access to e.g.
719 <filename>/etc</filename> or <filename>/var</filename> is not needed.</para>
720 </refsect2>
798d3a52
ZJS
721 </refsect1>
722
723 <refsect1>
724 <title>Node Types</title>
725
726 <para>Unix file systems support different types of file nodes,
727 including regular files, directories, symlinks, character and
728 block device nodes, sockets and FIFOs.</para>
729
5eb5f352 730 <para>It is strongly recommended that <filename>/dev/</filename> is
798d3a52 731 the only location below which device nodes shall be placed.
5eb5f352 732 Similarly, <filename>/run/</filename> shall be the only location to
798d3a52
ZJS
733 place sockets and FIFOs. Regular files, directories and symlinks
734 may be used in all directories.</para>
735 </refsect1>
736
737 <refsect1>
738 <title>System Packages</title>
739
fa26ff47
ZJS
740 <para>Developers of system packages should follow strict rules when placing their files in the file
741 system. The following table lists recommended locations for specific types of files supplied by the
742 vendor.</para>
798d3a52
ZJS
743
744 <table>
fa26ff47 745 <title>System package vendor files locations</title>
798d3a52
ZJS
746 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
747 <colspec colname="directory" />
748 <colspec colname="purpose" />
749 <thead>
750 <row>
751 <entry>Directory</entry>
752 <entry>Purpose</entry>
753 </row>
754 </thead>
755 <tbody>
756 <row>
5eb5f352 757 <entry><filename>/usr/bin/</filename></entry>
b938cb90 758 <entry>Package executables that shall appear in the <varname>$PATH</varname> executable search path, compiled for any of the supported architectures compatible with the operating system. It is not recommended to place internal binaries or binaries that are not commonly invoked from the shell in this directory, such as daemon binaries. As this directory is shared with most other packages of the system, special care should be taken to pick unique names for files placed here, that are unlikely to clash with other package's files.</entry>
798d3a52
ZJS
759 </row>
760 <row>
5eb5f352 761 <entry><filename>/usr/lib/<replaceable>arch-id</replaceable>/</filename></entry>
798d3a52
ZJS
762 <entry>Public shared libraries of the package. As above, be careful with using too generic names, and pick unique names for your libraries to place here to avoid name clashes.</entry>
763 </row>
764 <row>
5eb5f352 765 <entry><filename>/usr/lib/<replaceable>package</replaceable>/</filename></entry>
b938cb90 766 <entry>Private static vendor resources of the package, including private binaries and libraries, or any other kind of read-only vendor data.</entry>
798d3a52
ZJS
767 </row>
768 <row>
5eb5f352 769 <entry><filename>/usr/lib/<replaceable>arch-id</replaceable>/<replaceable>package</replaceable>/</filename></entry>
798d3a52
ZJS
770 <entry>Private other vendor resources of the package that are architecture-specific and cannot be shared between architectures. Note that this generally does not include private executables since binaries of a specific architecture may be freely invoked from any other supported system architecture.</entry>
771 </row>
772 <row>
5eb5f352 773 <entry><filename>/usr/include/<replaceable>package</replaceable>/</filename></entry>
798d3a52
ZJS
774 <entry>Public C/C++ APIs of public shared libraries of the package.</entry>
775 </row>
776 </tbody>
777 </tgroup>
778 </table>
779
780 <para>Additional static vendor files may be installed in the
5eb5f352 781 <filename>/usr/share/</filename> hierarchy to the locations
798d3a52
ZJS
782 defined by the various relevant specifications.</para>
783
fa26ff47
ZJS
784 <para>The following directories shall be used by the package for local configuration and files created
785 during runtime:</para>
798d3a52
ZJS
786
787 <table>
fa26ff47 788 <title>System package variable files locations</title>
798d3a52
ZJS
789 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
790 <colspec colname="directory" />
791 <colspec colname="purpose" />
792 <thead>
793 <row>
794 <entry>Directory</entry>
795 <entry>Purpose</entry>
796 </row>
797 </thead>
798 <tbody>
799 <row>
5eb5f352
LP
800 <entry><filename>/etc/<replaceable>package</replaceable>/</filename></entry>
801 <entry>System-specific configuration for the package. It is recommended to default to safe fallbacks if this configuration is missing, if this is possible. Alternatively, a <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> fragment may be used to copy or symlink the necessary files and directories from <filename>/usr/share/factory/</filename> during boot, via the <literal>L</literal> or <literal>C</literal> directives.</entry>
798d3a52
ZJS
802 </row>
803 <row>
5eb5f352 804 <entry><filename>/run/<replaceable>package</replaceable>/</filename></entry>
0458de11 805 <entry>Runtime data for the package. Packages must be able to create the necessary subdirectories in this tree on their own, since the directory is flushed automatically on boot. Alternatively, a <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> fragment may be used to create the necessary directories during boot, or the <varname>RuntimeDirectory=</varname> directive of service units may be used to create them at service startup (see <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details).</entry>
798d3a52
ZJS
806 </row>
807 <row>
5eb5f352 808 <entry><filename>/run/log/<replaceable>package</replaceable>/</filename></entry>
798d3a52
ZJS
809 <entry>Runtime log data for the package. As above, the package needs to make sure to create this directory if necessary, as it will be flushed on every boot.</entry>
810 </row>
811 <row>
5eb5f352 812 <entry><filename>/var/cache/<replaceable>package</replaceable>/</filename></entry>
0458de11 813 <entry>Persistent cache data of the package. If this directory is flushed, the application should work correctly on next invocation, though possibly slowed down due to the need to rebuild any local cache files. The application must be capable of recreating this directory should it be missing and necessary. To create an empty directory, a <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> fragment or the <varname>CacheDirectory=</varname> directive of service units (see <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>) may be used.</entry>
798d3a52
ZJS
814 </row>
815 <row>
5eb5f352 816 <entry><filename>/var/lib/<replaceable>package</replaceable>/</filename></entry>
0458de11 817 <entry>Persistent private data of the package. This is the primary place to put persistent data that does not fall into the other categories listed. Packages should be able to create the necessary subdirectories in this tree on their own, since the directory might be missing on boot. To create an empty directory, a <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> fragment or the <varname>StateDirectory=</varname> directive of service units (see <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>) may be used.</entry>
798d3a52
ZJS
818 </row>
819 <row>
5eb5f352 820 <entry><filename>/var/log/<replaceable>package</replaceable>/</filename></entry>
8dacdd28 821 <entry>Persistent log data of the package. As above, the package should make sure to create this directory if necessary, possibly using <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> or <varname>LogsDirectory=</varname> (see <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>), as it might be missing.</entry>
798d3a52
ZJS
822 </row>
823 <row>
5eb5f352 824 <entry><filename>/var/spool/<replaceable>package</replaceable>/</filename></entry>
798d3a52
ZJS
825 <entry>Persistent spool/queue data of the package. As above, the package should make sure to create this directory if necessary, as it might be missing.</entry>
826 </row>
827 </tbody>
828 </tgroup>
829 </table>
830 </refsect1>
831
832 <refsect1>
833 <title>User Packages</title>
834
fa26ff47
ZJS
835 <para>Programs running in user context should follow strict rules when placing their own files in the
836 user's home directory. The following table lists recommended locations in the home directory for specific
837 types of files supplied by the vendor if the application is installed in the home directory. (User
838 applications installed system-wide are covered by the rules outlined above for vendor files.)</para>
798d3a52
ZJS
839
840 <table>
fa26ff47 841 <title>Vendor package file locations under the home directory of the user</title>
798d3a52
ZJS
842 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
843 <colspec colname="directory" />
844 <colspec colname="purpose" />
845 <thead>
846 <row>
847 <entry>Directory</entry>
848 <entry>Purpose</entry>
849 </row>
850 </thead>
851 <tbody>
852 <row>
5eb5f352 853 <entry><filename>~/.local/bin/</filename></entry>
b938cb90 854 <entry>Package executables that shall appear in the <varname>$PATH</varname> executable search path. It is not recommended to place internal executables or executables that are not commonly invoked from the shell in this directory, such as daemon executables. As this directory is shared with most other packages of the user, special care should be taken to pick unique names for files placed here, that are unlikely to clash with other package's files.</entry>
798d3a52
ZJS
855 </row>
856 <row>
5eb5f352 857 <entry><filename>~/.local/lib/<replaceable>arch-id</replaceable>/</filename></entry>
fa26ff47 858 <entry>Public shared libraries of the package. As above, be careful with using overly generic names, and pick unique names for your libraries to place here to avoid name clashes.</entry>
798d3a52
ZJS
859 </row>
860 <row>
5eb5f352 861 <entry><filename>~/.local/lib/<replaceable>package</replaceable>/</filename></entry>
798d3a52
ZJS
862 <entry>Private, static vendor resources of the package, compatible with any architecture, or any other kind of read-only vendor data.</entry>
863 </row>
864 <row>
5eb5f352 865 <entry><filename>~/.local/lib/<replaceable>arch-id</replaceable>/<replaceable>package</replaceable>/</filename></entry>
798d3a52
ZJS
866 <entry>Private other vendor resources of the package that are architecture-specific and cannot be shared between architectures.</entry>
867 </row>
868 </tbody>
869 </tgroup>
870 </table>
871
fa26ff47
ZJS
872 <para>Additional static vendor files may be installed in the <filename>~/.local/share/</filename>
873 hierarchy, mirroring the subdirectories specified in the section "Vendor-supplied operating system
874 resources" above.</para>
798d3a52 875
fa26ff47
ZJS
876 <para>The following directories shall be used by the package for per-user local configuration and files
877 created during runtime:</para>
798d3a52
ZJS
878
879 <table>
fa26ff47 880 <title>User package variable file locations</title>
798d3a52
ZJS
881 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
882 <colspec colname="directory" />
883 <colspec colname="purpose" />
884 <thead>
885 <row>
886 <entry>Directory</entry>
887 <entry>Purpose</entry>
888 </row>
889 </thead>
890 <tbody>
891 <row>
5eb5f352 892 <entry><filename>~/.config/<replaceable>package</replaceable>/</filename></entry>
798d3a52
ZJS
893 <entry>User-specific configuration and state for the package. It is required to default to safe fallbacks if this configuration is missing.</entry>
894 </row>
895 <row>
5eb5f352 896 <entry><filename><varname>$XDG_RUNTIME_DIR</varname>/<replaceable>package</replaceable>/</filename></entry>
798d3a52
ZJS
897 <entry>User runtime data for the package.</entry>
898 </row>
899 <row>
5eb5f352 900 <entry><filename>~/.cache/<replaceable>package</replaceable>/</filename></entry>
b938cb90 901 <entry>Persistent cache data of the package. If this directory is flushed, the application should work correctly on next invocation, though possibly slowed down due to the need to rebuild any local cache files. The application must be capable of recreating this directory should it be missing and necessary.</entry>
798d3a52
ZJS
902 </row>
903 </tbody>
904 </tgroup>
905 </table>
906 </refsect1>
907
908 <refsect1>
909 <title>See Also</title>
910 <para>
911 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
912 <citerefentry project='man-pages'><refentrytitle>hier</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
913 <citerefentry><refentrytitle>systemd-path</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
59512f21 914 <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
798d3a52
ZJS
915 <citerefentry><refentrytitle>sysctl.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
916 <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
917 <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
918 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
919 </para>
920 </refsect1>
9546c6ed
LP
921
922</refentry>