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