All of these directories are, by default, subdirectories of the installation prefixes described in the previous section. However, the variables may be reset to locations outside the installation prefixes, and all profiles of this specification do this for some of the variables.
Most executable files
should be installed in this directory. (See Section 4.2.2, “sbindir: System management commands”
and Section 4.2.3, “libexecdir: Programs not meant to be run directly by a
human” for the exceptions.)
Mutable
and machine-specific
files may not be installed in this directory, even if they are executable.
Subdirectories may not be created within bindir.
Files that are not executable may not be installed in this directory, even if they are
in some sense “programs.” All files installed in bindir must be
recognizable by the system call execve as executable, assuming the CPU
and operating system support execution of that type of program. Software compliant with
this specification must not ever rely on the fallback behavior of the C library functions
execlp and execvp when execve
fails with code ENOEXEC.
The default value of bindir is
.$(exec_prefix)/bin
Shells do not search PATH for any command whose name contains slashes,
so it doesn’t work to try to use subdirectories of bindir as namespaces
for commands.
The fallback behavior of execlp and execvp
is to attempt to execute the offending file as if it were a /bin/sh
script. This has unpredictable consequences when the file isn’t
a /bin/sh script. It is also inconsistent with the behavior of
all the other exec* functions, and with the behavior of programming
languages that implement PATH search themselves rather than relying on
the C library to do it. Finally, it is fully obsoleted by the
#! mechanism.
Executable files that are exclusively useful to
the system administrator (e.g. fsck), and executables that implement
system services (e.g. sshd), should be installed in this directory.
The word “exclusively” in the previous sentence is intentional. If there is any
plausible situation where an unprivileged user might want to use a program, it should be
placed in bindir, not
sbindir.
All the requirements on files installed in bindir
also apply to files installed in sbindir.
Subdirectories may not be created within sbindir,
for the same reason this is forbidden for bindir.
The default value of sbindir is
.$(exec_prefix)/sbin
A profile may set sbindir equal to
bindir.
Therefore, software packages may not install files with the same base name
in both directories.
The division between bindir and sbindir was not
created for security reasons, or to prevent inquisitive users from seeing the operating system.
Rather, the goal was to remove programs that are not useful to unprivileged users from the
default PATH, thus reducing clutter in shell command completion and whatnot.
Therefore, sbindir should still be accessible to unprivileged users
and the programs within should still be readable and executable by unprivileged users.
Executable files that are primarily or exclusively meant to be run by other programs, rather than directly by humans, should be installed in this directory.
Executables that implement system services are an exception;
despite usually being run by another program (the system service
orchestrator), they should be installed in sbindir.
All the requirements on files installed in
bindir
also apply to files installed in libexecdir.
Unlike bindir, software packages may create subdirectories of
libexecdir and place executables within these subdirectories.
The default value of libexecdir is
.$(exec_prefix)/libexec
A profile may set libexecdir equal to
libdir.
Therefore, software packages may not install files with the
same relative pathname in both directories.
It is useful for the system administrator to be able to run programs that implement system services as ordinary shell commands, for troubleshooting and testing.
Programs that are run by other programs are usually invoked by their full pathname,
rather than relying on PATH search, so subdirectories of
libexecdir work as expected, and can be useful in avoiding filename
collisions.
System-wide configuration files—that is, editable
files, meant to modified by the system administrator, to adjust the default behavior of
one or more programs for an entire machine—should be installed in this directory.
Programs that need to install more than one or two configuration files in
sysconfdir should create an appropriately named subdirectory and place
all their configuration files inside.
Files that can be modified by individual users on a multi-user system, to adjust program behavior just for the user who modified them, may not be installed in this directory; they belong in users’ home directories. See Section 8.5, “User home directories”.
Files that define the default behavior of a program,
but are not intended to be modified, may not be installed in this directory;
they belong in datadir.
Installation processes must take care, when installing or updating files within
sysconfdir, not to overwrite any local modifications to existing files.
Add discussion of systemd-style drop-in directories and override files.
Executable files may only be installed in
sysconfdir if they are also “system-wide configuration files” as defined
at the beginning of this section.
(The shell scripts used by
System V init
to control startup and shutdown are a good example of executables that are also system-wide
configuration files.) Machine-code executables may not be used as configuration
files, because they are not editable.
I don’t love using a code-forge repo as a reference, even for an example; anyone know of a historical retrospective on init(8), or like that?
Mutable files may not be installed in this
directory; they belong in
localstatedir.
Programs are allowed to modify files in
sysconfdir, as long as they only do this during system maintenance
operations or as a consequence of an explicit human action. For example, the system package
manager will regularly need to alter files within sysconfdir when
packages are updated; this is a system maintenance operation, so it is compliant with this
specification. For another example, the passwd command’s entire purpose
is to update , but it
only does this when a human wants to change a password, so it is compliant, and its
existence does not mean $(sysconfdir)/shadow
should be considered mutable.$(sysconfdir)/shadow
The default value of sysconfdir is
.$(prefix)/etc
No files are required to exist within sysconfdir. There are many
files that almost always will exist, but nonetheless they should not be
assumed to exist.
When the C library provides an API for looking up data that is usually
stored in a well-known file within sysconfdir, there is no requirement
for the data to actually be sourced from that file. In many cases, the data won’t be
exclusively sourced from that file even when it does exist. Programs should therefore
prefer the library APIs whenever possible.
Should we still be requiring the locations below for SGML and XML catalog files? Abstractly it seems like they belong in localstatedir instead. I don’t know how they are currently handled in practice.
If the X Window System is installed, its configuration files must be placed
in this subdirectory of sysconfdir, not in their historical
location within libdir.
Centralized catalog files for all SGML DTDs installed on the system shall be installed in this directory.
A “super” catalog file, referencing all of the centralized catalogs,
shall be maintained at
.$(sysconfdir)/sgml/catalog
Configuration files relevant to multiple SGML processors may also be installed in this directory.
Centralized catalog files for all XML namespaces with schemas installed on the system shall be installed in this directory.
A “super” catalog file, referencing all of the centralized catalogs,
shall be maintained at
.$(sysconfdir)/xml/catalog
Configuration files relevant to multiple XML processors may also be installed in this directory.
“Header files” (files to be used as the direct object of the
#include preprocessing directive) for any programming
language in the C family should be placed in this directory.
C header files installed in this directory must be usable with an ISO C-compliant compiler, and should also be usable with a C++ compiler.
Executable, mutable, and machine-specific files may not be installed in this directory.
The default value of includedir is
.$(prefix)/include
The C family gets an installation directory exclusively for its header files because
of C’s historical importance as the principal system programming language for Unix systems.
It is not within datarootdir
both because of historical practice, and because C-family header files are frequently
architecture-dependent.
Machine-code libraries, whether statically or dynamically linked, should be installed in this directory.
Other
architecture-dependent
static
shareable
data files may also be installed in this directory,
when there is no more specific installation directory for them. Such files should be
installed into a subdirectory that identifies their purpose and/or format, unless there
is a compelling reason why they need to be directly in libdir.
Miscellaneous architecture-independent
static data files should instead be installed in datadir.
However, it can be difficult to tell whether a file is truly architecture-independent; when
in doubt, assume it isn’t.
Executable files may only be installed in
libdir if they are also machine-code libraries and they do not need to
be accessible as shell commands. (For example, GNU libc’s libc.so.6
is a machine-code library. It can be used as an executable, but this
is a secondary function that doesn’t require it to be visible in PATH.)
Mutable and machine-specific files may not be installed in this directory.
The default value of libdir is
.$(exec_prefix)/lib
This directory is reserved for installation of modular components of the OS kernel that do not need to be available to the bootloader, and files holding related information (e.g. a catalog of available modules). All files within this directory should be placed in subdirectories whose names identify the exact kernel that the modules are to be used with.
Architecture-independent static shareable data files should be installed in this directory, if there is no more specific installation directory for them. All such files should be installed into subdirectories that identify their purpose, format, and/or the application that created them.
Software packages may not install files directly in datadir.
Packages that need to install only a few files in datadir may use
instead of creating a directory in $(datadir)/miscdatadir.
Files which are
architecture-dependent,
executable,
mutable, or
machine-specific
may not be installed in this directory. It can be difficult to be certain that files are
architecture-independent; if there is any doubt, they should be placed in (a subdirectory
of) libdir instead.
The default value of datadir is
.$(datarootdir)
This directory offers an alternative to creating an application-specific subdirectory
of datarootdir. It should only be used by applications that install only
a few architecture-independent, shareable data files. Applications that install files in
this directory must take care to use names that will not collide with any other
application.
Here are a few examples of files that are suitable for installation in this directory.
Many of these files were, in the past, installed directly in datadir
or libdir.
| File | Description |
|---|---|
airport | List of IATA three-letter identifying codes for major airports |
ascii | ASCII character set table |
birthtoken | Traditional stone and flower for each month |
gprof.callg | Data used by gprof when processing call-graph profiles |
gprof.flat | Data used by gprof when processing flat profiles |
inter.phone | Country codes for international telephone calls |
magic | Rules for identifying file formats, used by the file command (textual) |
magic.mgc | Rules for identifying file formats, used by the file command (compiled) |
man.template | Template for writing manpages in ‘man’ format |
mdoc.template | Template for writing manpages in ‘mdoc’ format |
na.phone | North American (NANPA) area codes for telephone numbers |
operator | Precedence table for operators in the C language |
termcap | Terminal capability database (textual) |
termcap.db | Terminal capability database (compiled) |
units.lib | Database of units of measurement, used by the units command |
Packaged color management files that are potentially useful to more than one application should be installed in this directory.
All the requirements on files installed in
datadir
also apply to files installed in .$(datarootdir)/color
The top-level directory
may not contain any files; all files should be in subdirectories
which identify the files’ purpose and/or format. At present, we specify only one such
subdirectory: $(datarootdir)/color
stores color profiles in the ICC (International Color Consortium) v4 format
[icc-specs].$(datarootdir)/color/icc
Comprehensive lists of words in natural languages, for use by spelling checkers, should be installed in this directory.
All the requirements on files installed in
datadir
also apply to files installed in .$(datarootdir)/dict
Each list should be named using the English name for its language, in all lowercase
ASCII letters, e.g. french or hokkien.
When there is more than one spelling standard for a language, the common English identifier
for the spelling standard should be prefixed to the language name,
e.g. american-english and british-english. When
there are several word lists available for a single language and standard, suffixes may be
used to distinguish them, e.g. american-english-web2 and
american-english-cracklib-small.
For compatibility with historical practice, if English word lists are installed,
should be a
symbolic link to the word list for the system’s users’ preferred spelling standard for
English. Spelling checkers should avoid using this link; instead, they should allow each
user to select the word list they prefer, from all available.$(datarootdir)/dict/words
All word lists installed in this directory should be plain text files with one word on each line, in the preferred collation order for the language. Word lists should be encoded in UTF-8 unless it is absolutely necessary to do otherwise (e.g. a word list for a language whose script hasn’t been added to Unicode).
This directory only contains word lists because word lists are the only data files common to all spelling checkers.
Packaged printer descriptions in PostScript Printer Description (PPD) format
[ps-printer-desc], that are potentially useful to more than one
application, should be installed in this directory or a subdirectory. The organization
of files within
is unspecified.$(datarootdir)/ppd
All the requirements on files installed in
datadir
also apply to files installed in .$(datarootdir)/ppd
Packaged files useful to more than one SGML processor, such as ordinary catalogs
(not centralized catalogs, see
),
DTDs, entity definitions, and style sheets, should be placed in this directory.$(sysconfdir)/sgml
The top-level directory
may not contain any files; all files should be in subdirectories which identify the DTD
to which the files are relevant, or, if they are relevant to more than one DTD, otherwise
unambiguously identify the group of files within.$(datarootdir)/sgml
All the requirements on files installed in
datadir
also apply to files installed in .$(datarootdir)/sgml
Packaged files useful to more than one XML processor, such as schema definitions and
style sheets, should be placed in this directory. Centralized catalogs are not to be
installed in this directory; they belong in
.$(sysconfdir)/xml
The top-level directory
may not contain any files; all files should be in subdirectories which identify the
XML namespace to which the files are relevant, or, if they are relevant to more than
one namespace, otherwise unambiguously identify the group of files within.$(datarootdir)/xml
All the requirements on files installed in
datadir
also apply to files installed in .$(datarootdir)/xml
Files which help adapt a program to a particular community of humans (a locale) should be installed in subdirectories of this directory. For example, “catalogs” of messages emitted by a program, in several human languages, belong here.
All the requirements on files installed in
datadir
also apply to files installed in localedir.
The default value of localedir is
.$(datarootdir)/locale
Localization data is stored in a structured hierarchy of subdirectories of
localedir:
.
<locale>/<category>/<files>
This used to say that locale identification strings were taken from POSIX, but the current version of POSIX leaves the rules for locale names much vaguer than we want. Some of this text may belong in Section 2.1.2, “Locales”.
The <locale> component identifies the community of
humans. This component must be a locale identification string.
Locale identification strings have the form .
<language>[_<territory>][.<encoding>][@<modifier>]
The field identifies
the language or language family spoken in the community, using one of the two- or
three-letter language codes defined by ISO 639, written with
lowercase ASCII letters. Two-letter codes must be used for all languages that have one.<language>
The field, when
present, identifies the geographic territory of the community and/or the geographic
variant of the language family, using one of the two-letter country codes defined by
ISO 3166, written with uppercase ASCII letters.
For example, this is useful to distinguish peninsular Portuguese (<territory>pt_PT)
from Brazilian Portuguese (pt_BR).
I cut a bunch of text about “numbers of international standards” that was either outdated or just plain wrong. This should be revised to reflect how setlocale(3) and man(1) actually behave.
The field, when
present, identifies the character encoding preferred in the community. It should be in all
lowercase ASCII letters and digits with minimal punctuation, e.g. “<encoding>utf8”,
not “UTF-8.”
Can we say that when the <encoding> is
omitted the default is UTF-8, or is it still too soon for that?
The field,
when present, further categorizes the locale. It can be used to distinguish language
variants that are inadequately handled by the
<modifier>
component, or to allow for conflicting cultural requirements, such as competing definitions
of collating order. It should be in all lowercase ASCII letters and digits with minimal
punctuation.<territory>
The <category> component indicates what aspect of
the locale is governed by the files within. The categories and their functions are:
| Category | Governs |
|---|---|
LC_ADDRESS | Formatting of addresses and geography-related items |
LC_COLLATE | String collation |
LC_CTYPE | Character classification |
LC_IDENTIFICATION | Metadata describing the locale |
LC_MEASUREMENT | Settings related to measurements (e.g. metric versus US customary) |
LC_MESSAGES | Localizable natural-language messages |
LC_MONETARY | Formatting of monetary values |
LC_NAME | Formatting of salutations for persons |
LC_NUMERIC | Formatting of nonmonetary numeric values |
LC_PAPER | Settings related to the standard paper size |
LC_TELEPHONE | Formats to be used with telephone services |
LC_TIME | Formatting of date and time values |
Explain the <category> directories in more detail and
describe what files are to be installed in each.
Documentation in the format expected by the man command should be installed in subdirectories of this directory.
The default value of mandir is
.$(datarootdir)/man
All the requirements on files installed in
datadir
also apply to files installed in mandir.
Manual pages are stored in a structured hierarchy of subdirectories of
mandir:
[.
The <locale>/]man<section>[/<arch>]<locale> and <arch>
components of this hierarchy are optional, as described below.
Individual manual pages should be stored with file names that end with a numeric
suffix, matching their section number; for example, the manual page for the
ls command should be installed to man1/ls.1,
possibly within a <locale> directory.
Manual pages may be installed compressed, in which case the numeric suffix should be
followed by the usual suffix identifying the compression format,
e.g. man1/ls.1.gz for gzip-format compression.
As a precaution against name collisions, some large sets of package-specific manual
pages have an additional alphabetical suffix inserted right after the section number.
For example, the C function strvis might be provided by both the system
C library and the third-party libbsd library. The C library’s version of
the manpage should be installed as man3/strvis.3 and libbsd’s as
man3/strvis.3bsd.
The component of the
manual page directory hierarchy classifies each manual page into one of eight topic-based
“sections:”<section>
| Section | Documents | Details |
|---|---|---|
1 | User commands | Programs that are generally useful to all users of the system. |
2 | System calls | C library functions that are implemented as direct calls to OS kernel services. |
3 | Library functions | C library functions that are not just direct calls to OS kernel services. (They may still make use of system calls as part of what they do.) Documentation of library functions for other programming languages may also be placed in this section, but each such manpage must have an alphabetical name suffix (see above). |
4 | Devices | The interfaces to peripheral hardware provided by the device files found in
/dev, and the kernel interfaces
to networking protocol support. |
5 | File formats | Common file formats. Notably, documentation for system configuration files
(Section 4.2.4, “sysconfdir: Machine-specific, system-wide configuration files”) should be in this section. |
6 | Games | Programs that implement games. |
7 | Miscellaneous | All manpages that do not fit in any other section can be placed here. |
8 | System management commands | Programs that are exclusively useful to the system administrator,
and programs that implement system services. The relationship between
section 8 and section 1 is an exact parallel of the relationship between
sbindir and
bindir. |
The above does not appear to be an accurate description of the contents of man4 on my computer. Notably, all the networking address families are in man7.
Optionally, preformatted manual pages may be installed in a parallel set of
directories at the section level:
cat holds the preformatted
versions of the pages in <section>man.
Preformatted manual pages may not be installed without the corresponding source-format
manual pages. Cached copies of locally-formatted manual pages are not to be written back
to the directories for preformatted manual pages; they must be written to
<section>
instead.$(localstatedir)/cache/man
The component of the
manual page directory hierarchy supports simultaneous installation of manual pages written
in multiple languages. If this component is present, it must be a
locale identification string that
uniquely identifies the language for the manpages within that directory.<locale>
Systems which offer manual pages in only one language may omit the
component and store the
<locale> directories directly in
<section>mandir. Systems which offer manual pages in more than one language
should place all their manual pages in
subdirectories.<locale>
The component of the
manual page directory hierarchy supports simultaneous installation of several
architecture-specific variants of man pages, for device drivers and other software that is
tightly coupled to the computer’s hardware. It should only be used when necessary.<arch>
I cut the <arch> example because the ctrlaltdel(8)
command is not a good example: what it does is at least theoretically applicable to any
computer with a keyboard that has Ctrl, Alt, and Del keys, and in any case there would be no
reason to have multiple versions of this command that do different
things depending on the CPU architecture! Let’s find an example of something where one
would actually want manX/i386/foobie.X and
manX/aarch64/foobie.X to coexist and say different things,
please.
Documentation in the format expected by the info command should be installed in this directory.
All the requirements on files installed in
datadir
also apply to files installed in infodir.
Should we mention install-info(8) and/or the dir file here?
The default value of infodir is
.$(datarootdir)/info
Documentation in any format besides those used by man and info, such as HTML, PDF, and plain text, should be installed in subdirectories of this directory.
All the requirements on files installed in
datadir
also apply to files installed in docdir.
No files may be installed directly into docdir, only into a
subdirectory named after the software package whose documentation it is.
The default value of docdir is
.$(datarootdir)/doc
All persistent
mutable files that are part of an installable software
package should be installed to one of the subdirectories of localstatedir,
defined in subsections of this section. Files may not be installed directly in
localstatedir.
New subdirectories of localstatedir may be added in future
revisions of this specification. All such directories will have system-wide functions, as
the existing subdirectories do. Software packages may not unilaterally add new directories
to the top level of localstatedir.
Programs that use persistent mutable files need to take precautions against unexpected modifications by other processes on the same system; see Section 2.2.4, “Handling of mutable files” for further discussion.
The default value of localstatedir is
.$(prefix)/var
System services that do time-consuming work whose result can usefully be cached and
reused, such as computation or network downloads, should create a subdirectory of
and store cache
files within.$(localstatedir)/cache
Files stored in subdirectories of
may be expired in a
service-specific manner, by the system administrator, or both. The service must always be
able to recover from unexpected deletion of these files. The service-specific
directories will normally not be deleted, but services should
gracefully recreate them if necessary, as well.$(localstatedir)/cache
Files stored in subdirectories of
must remain valid across service restarts and system reboots.$(localstatedir)/cache
A few commonly used subdirectories of
are described
below. This specification makes no further requirements of the contents of
service-specific subdirectories that are not described below.$(localstatedir)/cache
The existence of a separate directory for cached data allows system administrators
to set different disk and backup policies from other directories in /var.
The directory
should be
used to store any dynamically-created font files. These files should be organized into
appropriately-named subdirectories rather than being placed directly in this
directory.$(localstatedir)/cache/fonts
Future revisions of this specification may make more specific requirements for the
organization of .
Other existing standards and software that describe directory hierarchies containing
fonts include the TeX Directory Structure [tex-directory-structure]
and fontconfig [fontconfig].
$(localstatedir)/cache/fonts
Cached copies of locally-formatted man pages should be stored in appropriately named subdirectories of this directory.
The directory structure below
mimics the directory structure below
$(localstatedir)/cache/man,
with an adjustment to allow for the possibility of multiple man page hierarchies.$(mandir)
Cached locally-formatted copies of the unformatted man pages stored in
shall be stored in
$(mandir)[/<locale>]/man<section>.
$(localstatedir)/cache/man/<catpath>[/<locale>]/cat<section>
is derived from the
<catpath>
component of $(prefix)
by removing a leading $(mandir)usr component, if present.
| Unformatted man page | Location for formatted page |
|---|---|
/usr/share/man/man1/ls.1 | |
/usr/local/share/man/pt_BR/man3/curl_easy_init.3 | |
Preformatted manpages that are included with a software package shall be
installed in mandir,
not in this directory.
Release 1.2 of this specification used
for this hierarchy. The path has been moved under
$(localstatedir)/catman
to better reflect the dynamic nature of the formatted man pages. The directory name has
been changed to $(localstatedir)/cacheman to allow for enhancing the hierarchy to include
post-processed formats other than “cat,” such as PostScript, HTML, or DVI.
For backward compatibility with old versions of the man
command, releases prior to 4.0 permitted locally formatted manpages to be written to
mandir; this is no longer allowed, as it conflicts with the general
policy that mutable files may not be stored in
mandir’s parent, datarootdir.
This hierarchy holds persistent mutable state information pertaining to an application or the system.
It should never be necessary to modify files in
to configure the system. All system-wide configuration files should be placed in
$(localstatedir)/libsysconfdir.
Additionally, the specific file hierarchy used to store data within
should not be exposed or relevant to regular users. Data whose filesystem structure is
necessarily relevant to regular users (such as the contents of a web site served by the
system) should be stored in $(localstatedir)/lib/srv
instead.
Data should only be stored in
if there is no more specific place to put it. In particular, cached data (files that can
safely be deleted at any time to recover disk space) belongs in
$(localstatedir)/lib;
spooled data (user-generated data awaiting automated processing) belongs in
$(localstatedir)/cache;
and system logs belong in
$(localstatedir)/spool.
$(localstatedir)/log
Files shall not be placed directly in
.
Each application (or group of inter-related applications) must create and use a
subdirectory of $(localstatedir)/lib
for its data, taking care to choose a name that will not collide with any other
application. Alternatively, applications that need to maintain only one or two persistent
mutable state files may place them in
$(localstatedir)/lib.
$(localstatedir)/lib/misc
Older versions of this specification did not require applications to use a subdirectory.
How old, exactly? Do we still need this note?
/var/lib/
is the location that must be used for all distribution packaging support. Different
distributions may use different names, of course.<name>
I don’t understand the preceding paragraph. It sounds like it’s picking a fight with some unspecified distribution from days of yore. Do we still need it? Can we clarify it?
This directory offers an alternative to creating an application-specific
subdirectory of .
It should only be used by applications that need to maintain only one or two persistent
mutable state files. Applications that install files in this directory must take care
to use names that will not collide with any other application.
$(localstatedir)/lib
As an exception to the normal rule that empty installation directories need not exist,
should be created at initial system installation time, and preserved, even when it is
empty. However, like all other installation directories, applications must be prepared
to cope with it not existing.$(localstatedir)/lib/misc
This specification recommends that the files stored in
in current BSD releases should be moved to this directory. These include
$(localstatedir)/dblocate.database and mountdtab,
and the kernel symbol database(s).
Do we want to keep making this recommendation? Have we actually had a
conversation with the BSD people, or any other relevant stakeholders, about
/var/db vs /var/lib(/misc)?
Editing tools that write state files during normal operation, may use a
subdirectory of
for this purpose, named after the editor. For example, the text editor elvis
might use $(localstatedir)/lib.$(localstatedir)/lib/elvis
Use of
is deprecated. Editors should instead place state files that are associated with a file
being edited, in the same directory as that file, whenever possible. When this is not
possible (e.g. when the user running the editor can modify a specific file in a
directory, but cannot create new files there), they should be placed in a suitable
location within the home directory of the user running the editor, as should state files
not associated with any particular file being edited. This is the behavior of current
versions of emacs and vim.$(localstatedir)/lib/<editor>
Examples of state files used by editors include: automatically saved copies of modifications to files that have not yet been explicitly saved, “lock” files that indicate a file is currently being edited, and data used to recover from a crash of the editor itself.
Historically, the vi editor used
to store
crash-recovery files. However, each editor uses its own format for its state files, so
a separate directory is needed for each editor.$(localstatedir)/preserve
has to be writable by all users on a multi-user system, which is troublesome for
security. Placing temporary state files alongside the file being edited, or else within
the home directory of the user running the editor, avoids the security issues.
See Section 2.2.4.1, “Security considerations for mutable files and world-writable directories” for further discussion.$(localstatedir)/lib/<editor>
This directory is the home for ICC color management files installed dynamically
(not as part of any software package). The contents of this directory shall follow the
same rules as the contents of the
directory.$(datarootdir)/color
This directory contains the file
,
which is created and updated by the hwclock command.
If the hwclock command is not used to maintain an accurate
real-time clock on the system, then this directory should not exist.$(localstatedir)/lib/hwclock/adjtime
The “real-time clock” is a battery-powered hardware clock that tracks calendar time and keeps running when the rest of the system is powered down. “Real time” in this context refers to calendar time, and has nothing to do with real-time task scheduling.
The real-time clock is often imprecise, compared to the timekeeping done by the operating system while the computer is running; one of the functions of hwclock is to monitor and compensate for its errors, using data stored in this file.
In FHS 2.1, this file was stored in sysconfdir,
but as it is a mutable file,
that location was inappropriate.
Applications that generate their own log files in the course of normal operation
should create a suitably named subdirectory of
at installation time, and write their log files to that directory. This specification
makes no requirements on the format or contents of application log files.$(localstatedir)/log
Applications that send their log records to the global system log
(syslog or equivalent) should not create any files or directories in
.$(localstatedir)/log
The following special-purpose files may exist at the top level of
.
If they exist, they shall have the indicated contents, and applications that generate
relevant log records should update them. However, applications must not create them if
they don’t already exist.$(localstatedir)/log
| File | Description |
|---|---|
lastlog | record of last login of each user |
btmp | record of failed logins |
wtmp | record of all logins and logouts |
Move all discussion of lastlog/btmp/wtmp/utmp/utmpx/wtmpx to its own section, document formats, mark as deprecated due to intractable Y2038 issues.
Otherwise, the top level of
is reserved for use
by the global system log. The software responsible for maintaining this log
(syslogd, historically) may create files and directories at the top
level with any names besides the ones listed above, taking care not to collide with
application-specific subdirectories, and use them as it sees fit.$(localstatedir)/log
Should we say something about log rotation here?
Applications which receive user-supplied data, store it, and process it in the
background, perhaps after some delay, should create a suitably named subdirectory of
at installation time, and store the user-supplied data there.$(localstatedir)/spool
Each application that stores user-supplied data in
is responsible for all management of files in its subdirectory. For example, often it
will be appropriate to delete files that have been completely processed.$(localstatedir)/spool
Common types of user-supplied data include:
This specification does not require any particular subdirectories to exist within
.
However, certain groups of files that historically were stored in
$(localstatedir)/spool
should now be placed elsewhere, and vice versa:$(localstatedir)/spool
$(runstatedir)/lock,
not in
$(localstatedir)/spool,
unless the resource they control access to
is a directory within
$(localstatedir)/spool.
See Section 4.2.18.1, “$(runstatedir)/lock: Lock
files”.$(localstatedir)/mail
or within user home directories, not in
$(localstatedir)/spool/mail.
See Section 4.2.17.5, “Special-purpose subdirectories of localstatedir”.$(localstatedir)/spool/rwho,
not in
$(localstatedir)/rwho.These directories are not installation directories; software
will generally not need to create files in them during its installation process. However,
software that uses these directories, or the data stored within,
should look for them relative to localstatedir.
All of these directories are optional; they should exist only if the relevant subsystem is in use.
| Directory | Description |
|---|---|
| This directory holds the current active process accounting log and the composite process usage data (as used in some UNIX-like systems by lastcomm and sa) |
| This directory holds system crash dumps, if the system is configured to produce them. |
| If the system delivers email to local users by writing them to files in the standard Unix mbox format [rfc4155], those files may be placed in this directory. Each file within this directory should have the same name as the account name of the local user whose mail it holds. |
| Variable data used by the Sun NIS+ system for network-wide user accounts should be placed in this directory. |
| Variable data used by the Sun NIS system (also known as Sun Yellow Pages) for network-wide user accounts should be placed in this directory. |
As of FHS 4.0, use of
for local mail delivery is discouraged. Locally delivered mail should instead be written
to an appropriate location within each local user’s home directory. Use of mbox-format
files is also discouraged. The format is underspecified, with several incompatible
variations seeing wide use, and it cannot efficiently handle large volumes of mail.$(localstatedir)/mail
Several more subdirectories of localstatedir were historically
common, but should not be used by new applications. They are:
$(localstatedir)/backups$(localstatedir)/cron$(localstatedir)/db$(localstatedir)/msgs$(localstatedir)/preserveThese directories are not required to exist.
Future revisions of this specification might either remove these directories altogether, or flesh out their expected contents and sanction their continued use.
Programs should store all their transient
mutable files in this directory or in one of its
subdirectories. Programs that need to create only one or two transient files may place
them directly in runstatedir; programs that need several transient
files should create a subdirectory and place all their files within.
Software packages should never install anything in this directory, because all files in this directory, and all subdirectories not listed below, are completely erased every time the system is booted. The variable exists to tell programs where to find this directory at runtime.
For the same reason, programs that use this directory must be prepared to recreate everything they put here, from scratch, every time they start up. However, they must not assume the files they mean to create don’t exist, either; garbage files might be left over from a previous run of the same program. See Section 2.2.4, “Handling of mutable files” for further discussion.
Because runstatedir’s contents are erased on every boot, it is an
exception to the normal rule that empty directories need not exist. For security reasons,
the top level of runstatedir is writable only by root.
System services that run as unprivileged users may therefore need to arrange for files and
directories that they need in runstatedir to be created in advance during
service startup.
The default value of runstatedir is
.$(prefix)/run
Daemon processes that create “process identifier” (PID) files should place them
directly within runstatedir and should name them
, where
<program-name>.pid<program-name> is the name of the daemon’s primary
executable (the one installed in sbindir). For example, the
crond daemon’s PID file should be named /run/crond.pid.
Each PID file should contain the daemon’s numeric PID as ASCII decimal digits, with no
padding on the left, followed by a newline character. For example, if
crond was running as process 25, /run/crond.pid
should contain three characters: 25␊.
Programs that create
local sockets
in order to provide system-wide services should place them within
runstatedir, but the exact pathname of each is unspecified.
The following special-purpose files may exist at the top level of
runstatedir. If they exist, they shall have the indicated contents,
and applications that generate relevant records should update them. However, applications
must not create them if they don’t already exist.
| File | Description |
|---|---|
utmp | Information about users currently logged in |
Move all discussion of lastlog/btmp/wtmp/utmp/utmpx/wtmpx to its own section, document formats, mark as deprecated due to intractable Y2038 issues.
PID files were historically placed in /etc, and local sockets
were historically placed in /tmp, /dev,
or localstatedir. PID files have been moved to
runstatedir because /etc is supposed to be as
read-only as possible in normal operation. Sockets formerly in /tmp
have been moved to runstatedir for security; sockets formerly in
/dev and localstatedir have also been moved,
for consistency and to reduce risk of name collisions.
is the
designated location for lock files. Lock files are
transient files whose existence indicates that
a system-wide resource is currently in use exclusively by one particular process.
The name of each lock file must unambiguously identify the resource that it mediates
access to. To work correctly, lock files must be created with an unusual sequence of
file operations; see Section 2.2.4.2, “Creation of lockfiles”.$(runstatedir)/lock
Nothing may be placed in
besides lock files and directories that group lock files into categories.$(runstatedir)/lock
Because runstatedir’s contents are erased on every boot,
is an exception to the
normal rule that empty directories need not exist. The boot step that erases the contents
of $(runstatedir)/lockrunstatedir must recreate
immediately
afterward.$(runstatedir)/lock
Unless there is a specific reason to do otherwise, all lock files should be ordinary text files, containing the process ID (PID) of the process holding the lock, as an ASCII decimal number, with a trailing newline. The process ID may be padded on the left with ASCII space characters.
All lock files for hardware devices must be placed directly in
.
The lock file for a specific device must be named
$(runstatedir)/lockLCK.., where
<device><device> is the base name of the device file.
For example, to lock /dev/ttyS0, create the file
.$(runstatedir)/lock/LCK..ttyS0
To ensure full compatibility with other programs that use device lock files,
the process ID within a device lock file must be padded on the left with ASCII spaces
to ten bytes wide. For example, if process 1230 has locked /dev/ttyS0,
then
must contain these eleven bytes: $(runstatedir)/lock/LCK..ttyS0␠␠␠␠␠␠1230␊, where ␠
is ASCII space and ␊ is ASCII newline.