1SYSUSERS.D(5) sysusers.d SYSUSERS.D(5)
2
3
4
6 sysusers.d - Declarative allocation of system users and groups
7
9 /etc/sysusers.d/*.conf
10
11 /run/sysusers.d/*.conf
12
13 /usr/lib/sysusers.d/*.conf
14
15 #Type Name ID GECOS Home directory Shell
16 u user_name uid "User Description" /path/to/shell
17 u user_name uid:gid - -
18 u user_name /file/owned/by/user - -
19 g group_name gid "Group Description"
20 g group_name /file/owned/by/group -
21 m user_name group_name
22 r - lowest-highest
23
25 systemd-sysusers uses the files from sysusers.d directory to create
26 system users and groups and to add users to groups, at package
27 installation or boot time. This tool may be used to allocate system
28 users and groups only, it is not useful for creating non-system (i.e.
29 regular, "human") users and groups, as it accesses /etc/passwd and
30 /etc/group directly, bypassing any more complex user databases, for
31 example any database involving NIS or LDAP.
32
34 Each configuration file shall be named in the style of package.conf or
35 package-part.conf. The second variant should be used when it is
36 desirable to make it easy to override just this part of configuration.
37
38 Files in /etc/sysusers.d override files with the same name in
39 /usr/lib/sysusers.d and /run/sysusers.d. Files in /run/sysusers.d
40 override files with the same name in /usr/lib/sysusers.d. Packages
41 should install their configuration files in /usr/lib/sysusers.d. Files
42 in /etc/sysusers.d are reserved for the local administrator, who may
43 use this logic to override the configuration files installed by vendor
44 packages. All configuration files are sorted by their filename in
45 lexicographic order, regardless of which of the directories they reside
46 in. If multiple files specify the same path, the entry in the file with
47 the lexicographically earliest name will be applied. All later entries
48 for the same user and group names will be logged as warnings.
49
50 If the administrator wants to disable a configuration file supplied by
51 the vendor, the recommended way is to place a symlink to /dev/null in
52 /etc/sysusers.d/ bearing the same filename.
53
55 The file format is one line per user or group containing name, ID,
56 GECOS field description, home directory, and login shell:
57
58 #Type Name ID GECOS Home directory Shell
59 u httpd 404 "HTTP User"
60 u _authd /usr/bin/authd "Authorization user"
61 u postgres - "Postgresql Database" /var/lib/pgsql /usr/libexec/postgresdb
62 g input - -
63 m _authd input
64 u root 0 "Superuser" /root /bin/zsh
65 r - 500-900
66
67 Empty lines and lines beginning with the "#" character are ignored, and
68 may be used for commenting.
69
70 Type
71 The type consists of a single letter. The following line types are
72 understood:
73
74 u
75 Create a system user and group of the specified name should they
76 not exist yet. The user's primary group will be set to the group
77 bearing the same name unless the ID field specifies it. The account
78 will be created disabled, so that logins are not allowed.
79
80 g
81 Create a system group of the specified name should it not exist
82 yet. Note that u implicitly creates a matching group. The group
83 will be created with no password set.
84
85 m
86 Add a user to a group. If the user or group do not exist yet, they
87 will be implicitly created.
88
89 r
90 Add a range of numeric UIDs/GIDs to the pool to allocate new UIDs
91 and GIDs from. If no line of this type is specified, the range of
92 UIDs/GIDs is set to some compiled-in default. Note that both UIDs
93 and GIDs are allocated from the same pool, in order to ensure that
94 users and groups of the same name are likely to carry the same
95 numeric UID and GID.
96
97 Name
98 The name field specifies the user or group name. The specified name
99 must consist only of the characters a-z, A-Z, 0-9, "_" and "-", except
100 for the first character which must be one of a-z, A-Z or "_" (i.e.
101 numbers and "-" are not permitted as first character). The user/group
102 name must have at least one character, and at most 31.
103
104 It is strongly recommended to pick user and group names that are
105 unlikely to clash with normal users created by the administrator. A
106 good scheme to guarantee this is by prefixing all system and group
107 names with the underscore, and avoiding too generic names.
108
109 For m lines, this field should contain the user name to add to a group.
110
111 For lines of type r, this field should be set to "-".
112
113 ID
114 For u and g, the numeric 32-bit UID or GID of the user/group. Do not
115 use IDs 65535 or 4294967295, as they have special placeholder meanings.
116 Specify "-" for automatic UID/GID allocation for the user or group
117 (this is strongly recommended unless it is strictly necessary to use a
118 specific UID or GID). Alternatively, specify an absolute path in the
119 file system. In this case, the UID/GID is read from the path's
120 owner/group. This is useful to create users whose UID/GID match the
121 owners of pre-existing files (such as SUID or SGID binaries). The
122 syntaxes "uid:gid" and "uid:groupname" are supported to allow creating
123 users with specific primary groups. The given group must be created
124 explicitly, or it must already exist. Specifying "-" for the UID in
125 these syntaxes is also supported.
126
127 For m lines, this field should contain the group name to add to a user
128 to.
129
130 For lines of type r, this field should be set to a UID/GID range in the
131 format "FROM-TO", where both values are formatted as decimal ASCII
132 numbers. Alternatively, a single UID/GID may be specified formatted as
133 decimal ASCII numbers.
134
135 GECOS
136 A short, descriptive string for users to be created, enclosed in
137 quotation marks. Note that this field may not contain colons.
138
139 Only applies to lines of type u and should otherwise be left unset (or
140 "-").
141
142 Home Directory
143 The home directory for a new system user. If omitted, defaults to the
144 root directory.
145
146 Only applies to lines of type u and should otherwise be left unset (or
147 "-"). It is recommended to omit this, unless software strictly requires
148 a home directory to be set.
149
150 Shell
151 The login shell of the user. If not specified, this will be set to
152 /usr/sbin/nologin, except if the UID of the user is 0, in which case
153 /bin/sh will be used.
154
155 Only applies to lines of type u and should otherwise be left unset (or
156 "-"). It is recommended to omit this, unless a shell different
157 /usr/sbin/nologin must be used.
158
160 Specifiers can be used in the "Name", "ID", "GECOS", "Home directory",
161 and "Shell" fields. An unknown or unresolvable specifier is treated as
162 invalid configuration. The following expansions are understood:
163
164 Table 1. Specifiers available
165 ┌──────────┬─────────────────┬─────────────────────┐
166 │Specifier │ Meaning │ Details │
167 ├──────────┼─────────────────┼─────────────────────┤
168 │"%b" │ Boot ID │ The boot ID of the │
169 │ │ │ running system, │
170 │ │ │ formatted as │
171 │ │ │ string. See │
172 │ │ │ random(4) for more │
173 │ │ │ information. │
174 ├──────────┼─────────────────┼─────────────────────┤
175 │"%H" │ Host name │ The hostname of the │
176 │ │ │ running system. │
177 ├──────────┼─────────────────┼─────────────────────┤
178 │"%m" │ Machine ID │ The machine ID of │
179 │ │ │ the running system, │
180 │ │ │ formatted as │
181 │ │ │ string. See │
182 │ │ │ machine-id(5) for │
183 │ │ │ more information. │
184 ├──────────┼─────────────────┼─────────────────────┤
185 │"%T" │ Directory for │ This is either /tmp │
186 │ │ temporary files │ or the path │
187 │ │ │ "$TMPDIR", "$TEMP" │
188 │ │ │ or "$TMP" are set │
189 │ │ │ to. │
190 ├──────────┼─────────────────┼─────────────────────┤
191 │"%v" │ Kernel release │ Identical to uname │
192 │ │ │ -r output. │
193 ├──────────┼─────────────────┼─────────────────────┤
194 │"%V" │ Directory for │ This is either │
195 │ │ larger and │ /var/tmp or the │
196 │ │ persistent │ path "$TMPDIR", │
197 │ │ temporary files │ "$TEMP" or "$TMP" │
198 │ │ │ are set to. │
199 ├──────────┼─────────────────┼─────────────────────┤
200 │"%%" │ Escaped "%" │ Single percent │
201 │ │ │ sign. │
202 └──────────┴─────────────────┴─────────────────────┘
203
205 Note that systemd-sysusers will do nothing if the specified users or
206 groups already exist or the users are members of specified groups, so
207 normally there is no reason to override sysusers.d vendor
208 configuration, except to block certain users or groups from being
209 created.
210
212 systemd(1), systemd-sysusers(8)
213
214
215
216systemd 245 SYSUSERS.D(5)