]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sysusers.d.xml
man: standarize on one-line license header
[thirdparty/systemd.git] / man / sysusers.d.xml
CommitLineData
21236ab5
LP
1<?xml version="1.0"?>
2<!--*-nxml-*-->
12b42c76 3<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
0307f791 4<!-- SPDX-License-Identifier: LGPL-2.1+ -->
e6de49ab 5<refentry id="sysusers.d" conditional='ENABLE_SYSUSERS'
798d3a52
ZJS
6 xmlns:xi="http://www.w3.org/2001/XInclude">
7
8 <refentryinfo>
9 <title>sysusers.d</title>
10 <productname>systemd</productname>
798d3a52
ZJS
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>sysusers.d</refentrytitle>
15 <manvolnum>5</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>sysusers.d</refname>
20 <refpurpose>Declarative allocation of system users and groups</refpurpose>
21 </refnamediv>
22
23 <refsynopsisdiv>
9b5c390f
YW
24 <para><filename>/etc/sysusers.d/*.conf</filename></para>
25 <para><filename>/run/sysusers.d/*.conf</filename></para>
798d3a52
ZJS
26 <para><filename>/usr/lib/sysusers.d/*.conf</filename></para>
27 </refsynopsisdiv>
28
29 <refsect1>
30 <title>Description</title>
31
7b1aaf66
ZJS
32 <para><command>systemd-sysusers</command> uses the files from
33 <filename>sysusers.d</filename> directory to create system users and groups and
34 to add users to groups, at package installation or boot time. This tool may be
35 used to allocate system users and groups only, it is not useful for creating
36 non-system (i.e. regular, "human") users and groups, as it accesses
37 <filename>/etc/passwd</filename> and <filename>/etc/group</filename> directly,
38 bypassing any more complex user databases, for example any database involving NIS
39 or LDAP.</para>
798d3a52
ZJS
40 </refsect1>
41
42 <refsect1>
8165be2e 43 <title>Configuration Directories and Precedence</title>
798d3a52
ZJS
44
45 <para>Each configuration file shall be named in the style of
46 <filename><replaceable>package</replaceable>.conf</filename> or
47 <filename><replaceable>package</replaceable>-<replaceable>part</replaceable>.conf</filename>.
48 The second variant should be used when it is desirable to make it
49 easy to override just this part of configuration.</para>
50
8165be2e
ZJS
51 <para>Files in <filename>/etc/sysusers.d</filename> override files
52 with the same name in <filename>/usr/lib/sysusers.d</filename> and
53 <filename>/run/sysusers.d</filename>. Files in
54 <filename>/run/sysusers.d</filename> override files with the same
55 name in <filename>/usr/lib/sysusers.d</filename>. Packages should
56 install their configuration files in
57 <filename>/usr/lib/sysusers.d</filename>. Files in
58 <filename>/etc/sysusers.d</filename> are reserved for the local
59 administrator, who may use this logic to override the
60 configuration files installed by vendor packages. All
61 configuration files are sorted by their filename in lexicographic
62 order, regardless of which of the directories they reside in. If
63 multiple files specify the same path, the entry in the file with
64 the lexicographically earliest name will be applied. All later
65 entries for the same user and group names will be logged as warnings.
66 </para>
67
68 <para>If the administrator wants to disable a configuration file
69 supplied by the vendor, the recommended way is to place a symlink
70 to <filename>/dev/null</filename> in
71 <filename>/etc/sysusers.d/</filename> bearing the same filename.
72 </para>
73 </refsect1>
74
75 <refsect1>
76 <title>Configuration File Format</title>
77
7b1aaf66
ZJS
78 <para>The file format is one line per user or group containing name, ID, GECOS
79 field description, home directory, and login shell:</para>
798d3a52 80
7b1aaf66
ZJS
81 <programlisting>#Type Name ID GECOS Home directory Shell
82u httpd 404 "HTTP User"
83u authd /usr/bin/authd "Authorization user"
84u postgres - "Postgresql Database" /var/lib/pgsql /usr/libexec/postgresdb
85g input - -
86m authd input
87u root 0 "Superuser" /root /bin/zsh</programlisting>
21236ab5 88
565dab8e
LP
89 <para>Empty lines and lines beginning with the <literal>#</literal> character are ignored, and may be used for
90 commenting.</para>
91
798d3a52
ZJS
92 <refsect2>
93 <title>Type</title>
94
95 <para>The type consists of a single letter. The following line
96 types are understood:</para>
97
98 <variablelist>
99 <varlistentry>
100 <term><varname>u</varname></term>
7b1aaf66
ZJS
101 <listitem><para>Create a system user and group of the specified name should
102 they not exist yet. The user's primary group will be set to the group
103 bearing the same name. The account will be created disabled, so that logins
104 are not allowed.</para></listitem>
798d3a52
ZJS
105 </varlistentry>
106
107 <varlistentry>
108 <term><varname>g</varname></term>
109 <listitem><para>Create a system group of the specified name
110 should it not exist yet. Note that <varname>u</varname>
111 implicitly create a matching group. The group will be
112 created with no password set.</para></listitem>
113 </varlistentry>
114
115 <varlistentry>
116 <term><varname>m</varname></term>
117 <listitem><para>Add a user to a group. If the user or group
cd72d204 118 do not exist yet, they will be implicitly
798d3a52
ZJS
119 created.</para></listitem>
120 </varlistentry>
121
122 <varlistentry>
123 <term><varname>r</varname></term>
124 <listitem><para>Add a range of numeric UIDs/GIDs to the pool
125 to allocate new UIDs and GIDs from. If no line of this type
b938cb90 126 is specified, the range of UIDs/GIDs is set to some
798d3a52
ZJS
127 compiled-in default. Note that both UIDs and GIDs are
128 allocated from the same pool, in order to ensure that users
129 and groups of the same name are likely to carry the same
130 numeric UID and GID.</para></listitem>
131 </varlistentry>
132
133 </variablelist>
134 </refsect2>
135
136 <refsect2>
137 <title>Name</title>
138
565dab8e
LP
139 <para>The name field specifies the user or group name. The specified name must consist only of the characters a-z,
140 A-Z, 0-9, <literal>_</literal> and <literal>-</literal>, except for the first character which must be one of a-z,
141 A-Z or <literal>_</literal> (i.e. numbers and <literal>-</literal> are not permitted as first character). The
142 user/group name must have at least one character, and at most 31.</para>
143
144 <para>It is strongly recommended to pick user and group names that are unlikely to clash with normal users
145 created by the administrator. A good scheme to guarantee this is by prefixing all system and group names with the
146 underscore, and avoiding too generic names.</para>
798d3a52 147
b938cb90 148 <para>For <varname>m</varname> lines, this field should contain
798d3a52
ZJS
149 the user name to add to a group.</para>
150
b938cb90 151 <para>For lines of type <varname>r</varname>, this field should
798d3a52
ZJS
152 be set to <literal>-</literal>.</para>
153 </refsect2>
154
155 <refsect2>
156 <title>ID</title>
157
b938cb90
JE
158 <para>For <varname>u</varname> and <varname>g</varname>, the
159 numeric 32-bit UID or GID of the user/group. Do not use IDs 65535
798d3a52
ZJS
160 or 4294967295, as they have special placeholder meanings.
161 Specify <literal>-</literal> for automatic UID/GID allocation
7b1aaf66
ZJS
162 for the user or group (this is strongly recommended unless it is strictly
163 necessary to use a specific UID or GID). Alternatively, specify an absolute path
b938cb90 164 in the file system. In this case, the UID/GID is read from the
798d3a52
ZJS
165 path's owner/group. This is useful to create users whose UID/GID
166 match the owners of pre-existing files (such as SUID or SGID
4cb41413
MV
167 binaries).
168 The syntax <literal><replaceable>uid</replaceable>:<replaceable>gid</replaceable></literal> is also supported to
1825c909
MV
169 allow creating user and group pairs with different numeric UID and GID values. The group with the indicated GID must get created explicitly before or it must already exist. Specifying <literal>-</literal> for the UID in this syntax
170 is also supported.
4cb41413 171 </para>
798d3a52 172
b938cb90 173 <para>For <varname>m</varname> lines, this field should contain
798d3a52
ZJS
174 the group name to add to a user to.</para>
175
b938cb90 176 <para>For lines of type <varname>r</varname>, this field should
798d3a52 177 be set to a UID/GID range in the format
b938cb90 178 <literal>FROM-TO</literal>, where both values are formatted as
798d3a52
ZJS
179 decimal ASCII numbers. Alternatively, a single UID/GID may be
180 specified formatted as decimal ASCII numbers.</para>
181 </refsect2>
182
183 <refsect2>
184 <title>GECOS</title>
185
7b1aaf66
ZJS
186 <para>A short, descriptive string for users to be created, enclosed in
187 quotation marks. Note that this field may not contain colons.</para>
798d3a52 188
7b1aaf66
ZJS
189 <para>Only applies to lines of type <varname>u</varname> and should otherwise
190 be left unset (or <literal>-</literal>).</para>
798d3a52
ZJS
191 </refsect2>
192
193 <refsect2>
194 <title>Home Directory</title>
195
7b1aaf66
ZJS
196 <para>The home directory for a new system user. If omitted, defaults to the
197 root directory.</para>
798d3a52 198
7b1aaf66
ZJS
199 <para>Only applies to lines of type <varname>u</varname> and should otherwise
200 be left unset (or <literal>-</literal>). It is recommended to omit this, unless
201 software strictly requires a home directory to be set.</para>
202 </refsect2>
203
204 <refsect2>
205 <title>Shell</title>
206
207 <para>The login shell of the user. If not specified, this will be set to
208 <filename>/sbin/nologin</filename>, except if the UID of the user is 0, in
209 which case <filename>/bin/sh</filename> will be used.</para>
210
211 <para>Only applies to lines of type <varname>u</varname> and should otherwise
212 be left unset (or <literal>-</literal>). It is recommended to omit this, unless
213 a shell different <filename>/sbin/nologin</filename> must be used.</para>
798d3a52 214 </refsect2>
798d3a52
ZJS
215 </refsect1>
216
33ab22fc
YW
217 <refsect1>
218 <title>Specifiers</title>
219
220 <para>Specifiers can be used in the "Name", "ID", "GECOS", "Home directory", and "Shell" fields.
221 An unknown or unresolvable specifier is treated as invalid configuration.
222 The following expansions are understood:</para>
223 <table>
224 <title>Specifiers available</title>
225 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
226 <colspec colname="spec" />
227 <colspec colname="mean" />
228 <colspec colname="detail" />
229 <thead>
230 <row>
231 <entry>Specifier</entry>
232 <entry>Meaning</entry>
233 <entry>Details</entry>
234 </row>
235 </thead>
236 <tbody>
237 <row>
238 <entry><literal>%b</literal></entry>
239 <entry>Boot ID</entry>
240 <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
241 </row>
242 <row>
243 <entry><literal>%H</literal></entry>
244 <entry>Host name</entry>
245 <entry>The hostname of the running system.</entry>
246 </row>
247 <row>
248 <entry><literal>%m</literal></entry>
249 <entry>Machine ID</entry>
250 <entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
251 </row>
252 <row>
253 <entry><literal>%T</literal></entry>
254 <entry>Directory for temporary files</entry>
255 <entry>This is either <filename>/tmp</filename> or the path <literal>$TMPDIR</literal>, <literal>$TEMP</literal> or <literal>$TMP</literal> are set to.</entry>
256 </row>
257 <row>
258 <entry><literal>%v</literal></entry>
259 <entry>Kernel release</entry>
260 <entry>Identical to <command>uname -r</command> output.</entry>
261 </row>
262 <row>
263 <entry><literal>%V</literal></entry>
264 <entry>Directory for larger and persistent temporary files</entry>
265 <entry>This is either <filename>/var/tmp</filename> or the path <literal>$TMPDIR</literal>, <literal>$TEMP</literal> or <literal>$TMP</literal> are set to.</entry>
266 </row>
267 <row>
268 <entry><literal>%%</literal></entry>
269 <entry>Escaped <literal>%</literal></entry>
270 <entry>Single percent sign.</entry>
271 </row>
272 </tbody>
273 </tgroup>
274 </table>
275 </refsect1>
276
798d3a52
ZJS
277 <refsect1>
278 <title>Idempotence</title>
279
7b1aaf66
ZJS
280 <para>Note that <command>systemd-sysusers</command> will do nothing if the
281 specified users or groups already exist or the users are members of specified
282 groups, so normally there is no reason to override
283 <filename>sysusers.d</filename> vendor configuration, except to block certain
284 users or groups from being created.</para>
798d3a52
ZJS
285 </refsect1>
286
287 <refsect1>
288 <title>See Also</title>
289 <para>
290 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
291 <citerefentry><refentrytitle>systemd-sysusers</refentrytitle><manvolnum>8</manvolnum></citerefentry>
292 </para>
293 </refsect1>
21236ab5
LP
294
295</refentry>