X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=man%2Ffile-hierarchy.xml;h=9d96cff007d3b143476ea75da8b33824c34d103a;hp=b0d0e97ee745c66dffbadb18039fb8ab683964e8;hb=06b643e7f5a3b79005dd57497897ab7255fe3659;hpb=9fc25924bef99b3bb522dff785fa56a8e886cb2f diff --git a/man/file-hierarchy.xml b/man/file-hierarchy.xml index b0d0e97ee..9d96cff00 100644 --- a/man/file-hierarchy.xml +++ b/man/file-hierarchy.xml @@ -54,14 +54,19 @@ systemd1 system and service manager are organized based on a file system hierarchy inspired by UNIX, more - specificaly the hierarchy described in the File System Hierarchy specification and - hier7. This + hier7. This manual page describes a more minimal, modernized subset of these specifications that defines more strictly the suggestions and restrictions systemd makes on the file system hierarchy. + + Many of the paths described here are queriable + with the + systemd-path1 + tool. @@ -74,12 +79,8 @@ root. Usually writable, but this is not required. Possibly a temporary file system (tmpfs). Not shared with - other hosts (unless read-only). The - administrator may create additional - top-level subdirectories in this tree, - if required and the name does not - conflict with any of the directories - listed below. + other hosts (unless read-only). + @@ -88,9 +89,9 @@ used for bringing up the system. On EFI systems this is possibly the EFI System Partition, also see - systemd-boot-generator8. This + systemd-efi-boot-generator8. This directory is usually strictly local - the host, and should be considered + to the host, and should be considered read-only, except when a new kernel or boot loader is installed. This directory only exists on systems that @@ -124,9 +125,9 @@ system users. This directory and possibly the directories contained within it might only become available - or writable in late boot or even on - user login only. This directory might - be placed on limited-functionality + or writable in late boot or even only + after user authentication. This directory + might be placed on limited-functionality network file systems, hence applications should not assume the full set of file API is available on @@ -169,7 +170,7 @@ The place for small temporary files. This directory is usually mounted as - tmpfs instance, and + a tmpfs instance, and should hence not be used for larger files. (Use /var/tmp for @@ -177,19 +178,21 @@ accessible to other users of the system it is essential that this directory is only written to with the - mkstemp3, - mkdtemp3 + mkstemp3, + mkdtemp3 and related calls. This directory is usually flushed at boot-up. Also, files that are not accessed within a certain time are usually automatically deleted. If applications find the environment variable - $TMP set they + $TMPDIR set they should prefer using the directory specified in it over directly referencing - /tmp. + /tmp (see environ7 + and + IEEE Std 1003.1 for details). @@ -206,7 +209,7 @@ for system packages to place runtime data in. This directory is flushed on boot, and generally writable for - priviliged programs + privileged programs only. Always writable. @@ -225,7 +228,7 @@ /run/user Contains per-user runtime directories, each usually - invidually mounted + individually mounted tmpfs instances. Always writable, flushed at each reboot and when the user logs @@ -261,8 +264,9 @@ /usr/bin - Binaries for user - commands, that shall appear in the + Binaries and + executables for user commands, that + shall appear in the $PATH search path. It is recommended not to place binaries in this directory that are @@ -282,29 +286,46 @@ /usr/lib - System libraries and - package-specific - data. - + Static, private vendor + data that is compatible with all + architectures (though not necessarily + architecture-independent). Note that + this includes internal executables or + other binaries that are not regularly + invoked from a shell. Such binaries + may be for any architecture supported + by the system. Do not place public + libraries in this directory, use + $libdir (see + below), instead. + + + + /usr/lib/arch-id + Location for placing + dynamic libraries, also called $libdir. + The architecture identifier to use is defined on Multiarch Architecture Specifiers (Tuples) + list. Legacy locations of $libdir are + /usr/lib, + /usr/lib64. + This directory should not + be used for package-specific data, + unless this data is + architecture-dependent, too. To query + $libdir for the + primary architecture of the system, + invoke: + # pkg-config --variable=libdir systemd or + # systemd-path system-library-arch + - - /usr/lib64 - Secondary library - directory for placing 64bit versions - of system libraries in, if the primary - architecture of the system is 32bit, - and /usr/lib64 is - defined in the platform ABI. This - directory should not be used for - package-specific data, unless this - data requires 64bit-specific versions, - too. /usr/share Resources shared - betwen multiple packages, such as + between multiple packages, such as documentation, man pages, time zone information, fonts and other resources. Usually, the precise @@ -403,7 +424,7 @@ private logs in this directory, though it is recommended to do most logging via the - syslog3 + syslog3 and sd_journal_print3 calls. @@ -433,16 +454,17 @@ restrictions as with /tmp apply, and hence only - mkstemp3, - mkdtemp3 + mkstemp3, + mkdtemp3 or similar calls should be used to make use of this directory. If applications find the environment - variable $TMP set - they should prefer using the directory - specified in it over directly - referencing - /var/tmp. + variable $TMPDIR + set they should prefer using the + directory specified in it over + directly referencing + /var/tmp (see environ7 + for details). @@ -457,7 +479,7 @@ /dev The root directory for device nodes. Usually this directory - is mounted as + is mounted as a devtmpfs instance, but might be of a different type in sandboxed/containerized setups. This @@ -490,7 +512,7 @@ programs) or $XDG_RUNTIME_DIR (for user programs) instead of POSIX - shared memory segments, since they + shared memory segments, since those directories are not world-writable and hence not vulnerable to security-sensitive name @@ -505,7 +527,7 @@ is mostly an API to interface with the kernel and not a place where normal files may be stored. For details, see - proc5. A + proc5. A number of special purpose virtual file systems might be mounted below this directory. @@ -568,23 +590,23 @@ This compatibility symlink points to /usr/lib, - ensuring that binaries referencing + ensuring that programs referencing this legacy path correctly find - their libraries. + their resources. /lib64 - This compatibility - symlink points to - /usr/lib64, + On some architecture + ABIs this compatibility symlink points + to $libdir, ensuring that binaries referencing this legacy path correctly find their - libraries. This symlink only exists on - architectures whose ABI requires a - 64bit version of the library - directory. + dynamic loader. This symlink only + exists on architectures whose ABI + places the dynamic loader in this + path. @@ -601,16 +623,175 @@ + + Home Directory + + User applications may want to place files and + directories in the user's home directory. They should + follow the following basic structure. Note that some + of these directories are also standardized (though + more weakly) by the XDG + Base Directory Specification. Additional + locations for high-level user resources are defined by + xdg-user-dirs. + + + + ~/.cache + + Persistent user cache + data. User programs may place + non-essential data in this + directory. Flushing this directory + should have no effect on operation of + programs, except for increased + runtimes necessary to rebuild these + caches. If an application finds + $XDG_CACHE_HOME set + is should use the directory specified + in it instead of this + directory. + + + + ~/.config + + Application + configuration and state. When a new + user is created this directory will be + empty or not exist at + all. Applications should fall back to + defaults should their configuration or + state in this directory be missing. If + an application finds + $XDG_CONFIG_HOME set + is should use the directory specified + in it instead of this + directory. + + + + ~/.local/bin + + Executables that shall + appear in the user's + $PATH search + path. It is recommended not to place + executables in this directory that are + not useful for invocation from a + shell; these should be placed in a + subdirectory of + ~/.local/lib + instead. Care should be taken when + placing architecture-dependent + binaries in this place which might be + problematic if the home directory is + shared between multiple hosts with + different + architectures. + + + + ~/.local/lib + + Static, private vendor + data that is compatible with all + architectures. + + + + ~/.local/lib/arch-id + + Location for placing + public dynamic libraries. The architecture + identifier to use, is defined on Multiarch Architecture Specifiers (Tuples) + list. + + + + ~/.local/share + + Resources shared + between multiple packages, such as + fonts or artwork. Usually, the precise + location and format of files stored + below this directory is subject to + specifications that ensure + interoperability. If + an application finds + $XDG_DATA_HOME set + is should use the directory specified + in it instead of this + directory. + + + + + + + + Unprivileged Write Access + + Unprivileged processes generally lack + write access to most of the hierarchy. + + The exceptions for normal users are + /tmp, + /var/tmp, + /dev/shm, as well as the home + directory $HOME (usually found + below /home) and the runtime + directory $XDG_RUNTIME_DIR (found + below /run/user) of the + user, which are all writable. + + For unprivileged system processes only + /tmp, + /var/tmp and + /dev/shm are writable. If an + unprivileged system process needs a private, writable + directory in /var or + /run, it is recommended to either + create it before dropping privileges in the daemon + code, to create it via + tmpfiles.d5 + fragments during boot, or via the + RuntimeDirectory= directive of + service units (see + systemd.unit5 + for details). + + + + Node Types + + Unix file systems support different types of file + nodes, including regular files, directories, symlinks, + character and block device nodes, sockets and FIFOs. + + It is strongly recommended that + /dev is the only location below + which device nodes shall be placed. Similar, + /run shall be the only location + to place sockets and FIFOs. Regular files, + directories and symlinks may be used in all + directories. + + System Packages Developers of system packages should follow strict rules when placing their own files in the file system. The following table lists recommended - locations for specific types of files. + locations for specific types of files supplied by the + vendor. - System Package Data Location + System Package Vendor Files Locations @@ -623,43 +804,63 @@ /usr/bin - Package executables that shall appear in the $PATH executable search path. 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 take to pick unique names for files placed here, that are unlikely to clash with other package's files. + Package executables that shall appear in the $PATH 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. - /usr/lib - Public shared libraries of the package, compiled for the primary architecture of the operating system. As above, be careful with using too generic names, and pick unique names for your libraries to place here to avoid name clashes. + /usr/lib/arch-id + 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. /usr/lib/package - Private other vendor resources of the package, including private binaries and libraries, but also including any other kind of read-only vendor data. - - - /usr/lib64 - Public shared libraries of the package, compiled for the secondary, 64bit architecture, if this is part of the platform ABI of the architecture. + Private, static vendor resources of the package, including private binaries and libraries, or any other kind of read-only vendor data. - /usr/lib64/package - Private other vendor resources of the package that are architecture-specific and cannot be shared between primary and secondary architectures. Note that this generally does not include private binaries since binaries of the primary architecture may generally be invoked from secondary architecture code just fine. + /usr/lib/arch-id/package + 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. /usr/include/package Public C/C++ APIs of public shared libraries of the package. + + +
+ + Additional static vendor files may be installed + in the /usr/share hierarchy, to + the locations defined by the various relevant + specifications. + + During runtime and for local configuration and + state additional directories are defined: + + + System Package Variable Files Locations + + + + + + Directory + Purpose + + + /etc/package - 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 tmpfiles.d5 fragment may be used to copy or symlink the necessary files and directores from /usr/share/factory during boot, via the L or C directives. + 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 tmpfiles.d5 fragment may be used to copy or symlink the necessary files and directories from /usr/share/factory during boot, via the L or C directives. /run/package - 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 tmpfiles.d5 fragment may be used to create the necessary directories during boot. + 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 tmpfiles.d5 fragment may be used to create the necessary directories during boot. Alternatively, the RuntimeDirectory= directive of service units may be used (see systemd.unit5 for details.) /run/log/package - Runtime log data for the package. + 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. /var/cache/package - Persistent cache data of the package. If this directory is flushed the application should work correctly on next invocation, though possibly slowed done due to the need to rebuild any local cache files. + 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. /var/lib/package @@ -667,11 +868,93 @@ /var/log/package - Persistent log data of the package. + Persistent log data of the package. As above, the package should make sure to create this directory if necessary, as it might be missing. /var/spool/package - Persistent spool/queue data of the package. + 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. + + + +
+
+ + + User Packages + + Programs running in user context should follow + strict rules when placing their own files in the + user's home directory. The following table lists + recommended locations in the home directory for + specific types of files supplied by the vendor if the + application is installed in the home directory. (Note + however, that user applications installed system-wide + should follow the rules outlined above regarding + placing vendor files.) + + + User Package Vendor File Locations + + + + + + Directory + Purpose + + + + + ~/.local/bin + Package executables that shall appear in the $PATH 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. + + + ~/.local/lib/arch-id + 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. + + + ~/.local/lib/package + Private, static vendor resources of the package, compatible with any architecture, or any other kind of read-only vendor data. + + + ~/.local/lib/arch-id/package + Private other vendor resources of the package that are architecture-specific and cannot be shared between architectures. + + + +
+ + Additional static vendor files may be installed + in the ~/.local/share hierarchy, + to the locations defined by the various relevant + specifications. + + During runtime and for local configuration and + state additional directories are defined: + + + User Package Variable File Locations + + + + + + Directory + Purpose + + + + + ~/.config/package + User-specific configuration and state for the package. It is required to default to safe fallbacks if this configuration is missing. + + + $XDG_RUNTIME_DIR/package + User runtime data for the package. + + + ~/.cache/package + 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. @@ -682,9 +965,13 @@ See Also systemd1, - hier7, - systemd-boot-generator8, + hier7, + systemd-path1, + systemd-efi-boot-generator8, sysctl.d5, + tmpfiles.d5, + pkg-config1, + systemd.unit5