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