SYSTEMD-SYSUSERS(8)
๐ SYSTEMD-SYSUSERS ๐
okay bestie, welcome to the page about systemd-sysusers and its little service twin systemd-sysusers.service โ they're the ones that โจallocate system users and groupsโจ for you. no cap, this is the tool that makes users and groups exist so you don't have to hand-edit /etc/passwd like some kind of medieval peasant ๐ง
โจ SYNOPSIS โจ
systemd-sysusers [OPTIONS...] [CONFIGFILE...]
systemd-sysusers.service
๐ธ DESCRIPTION ๐ธ
so like, systemd-sysusers creates system users and groups, and it does it based on files in the format described over in sysusers.d(5). that's the whole vibe. ๐
if you run it with no arguments at all, it executes the directives from the configuration files it finds in the directories specified by sysusers.d(5). simple, clean, iconic.
but when you invoke it with positional arguments, it gets a lil more interesting:
- if
--replace=PATHis specified, the arguments on the command line are used instead of the configuration filePATH. - otherwise, only the configuration specified by the command line arguments gets executed.
- if the string
-is given instead of a filename, the configuration is read from standard input ๐ซถ - if the argument is a file name (no slashes in it, bestie), then all the configuration directories get searched for a matching file, and the file found with the highest priority is the one that gets executed.
- if the argument is a path, that file is used directly โ no searching the configuration directories for any other matching file. it said what it said. periodt.
๐ OPTIONS ๐
here's everything it understands, no gatekeeping:
--root=root โ takes a directory path as its argument. all paths get prefixed with the given alternate root path, including config search paths.
โ ๏ธ note that this is not a sandboxing or security feature, bestie. sysusers.d(5) definitions are potentially not processed in a hermetic fashion to the specified root. so don't be out here thinking it's a security boundary, because it is not. ๐
Added in version 215.
--image=image โ takes a path to a disk image file or block device node. if specified, all operations get applied to the file system in the indicated disk image. this is similar to--root=but it operates on file systems stored in disk images or block devices. the disk image should either contain just a file system, or a set of file systems within a GPT partition table, following the UAPI.2 Discoverable Partitions Specification[1]. for more info on supported disk images, go look atsystemd-nspawn(1)'s switch of the same name. ๐ซ
Added in version 247.
--image-policy=policy โ takes an image policy string as argument, as persystemd.image-policy(7). the policy is enforced when operating on the disk image specified via--image=, see above. if you don't specify it, it defaults to the"*"policy, i.e. all recognized file systems in the image are used.--replace=PATHโ when this option is given, one or more positional arguments must be specified. all configuration files found in the directories listed insysusers.d(5)will be read, and the configuration given on the command line will be handled instead of and with the same priority as the configuration filePATH.
this option is intended for when package installation scripts are running and the files belonging to that package aren't on disk yet, so their contents have to come from the command line โ but the admin configuration might already exist and should get higher priority. iykyk. ๐
Example 1. RPM installation script for radvd
echo 'u radvd - "radvd daemon"' | \
systemd-sysusers --replace=/usr/lib/sysusers.d/radvd.conf -
this will create the radvd user as if /usr/lib/sysusers.d/radvd.conf was already on disk. an admin might override the configuration specified on the command line by placing /etc/sysusers.d/radvd.conf or even /etc/sysusers.d/00-overrides.conf.
note that this is the expanded form, and when used in a package, this would be written using a macro with "radvd" and a file containing the configuration line as arguments.
Added in version 238.
-n,--dry-runโ process the configuration and figure out what entries would be created, but don't actually write anything. it's the "manifesting" option fr fr. the short option-nwas added in version 262.
Added in version 250.
--inlineโ treat each positional argument as a separate configuration line instead of a file name.
Added in version 238.
--cat-configโ copy the contents of config files to standard output. before each file, the filename is printed as a comment. ๐--tldrโ copy the contents of config files to standard output, but only the "interesting" parts. comments and empty lines get skipped, because we're busy. before each file, the filename is printed as a comment.--no-pagerโ do not pipe output into a pager. sometimes you just want it all dumped straight to the terminal, and honestly? valid.-h,--helpโ print a short help text and exit. ๐ฆ--versionโ print a short version string and exit.
๐ CREDENTIALS ๐
systemd-sysusers supports the service credentials logic as implemented by ImportCredential=, LoadCredential= and SetCredential= (see systemd.exec(5) for the deets). these are the credentials used when they get passed in:
passwd.hashed-password.userโ a UNIX hashed password string to use for the specified user, when creating an entry for it. this is particularly useful for the"root"user, since it lets you provision the default root password to use via a unit file drop-in, or from a container manager passing in this credential. note that setting this credential has no effect if the specified user account already exists. so this credential is primarily useful in first boot scenarios, or systems that are fully stateless and come up with an empty/etc/on every boot. ๐
Added in version 249.
passwd.plaintext-password.userโ same energy as"passwd.hashed-password.user", except it expects a literal, plaintext password, which then gets automatically hashed before it's used for the user account. if both the hashed and the plaintext credential are specified for the same user, the former takes precedence. it's generally recommended to specify the hashed version; however, in test environments with weaker requirements on security it might be easier to pass passwords in plaintext instead. ๐
Added in version 249.
passwd.shell.userโ specifies the shell binary to use for the specified account when creating it.
Added in version 249.
sysusers.extraโ the contents of this credential may contain additional lines to operate on. the credential contents should follow the same format as any othersysusers.d/drop-in. if this credential is passed, it gets processed after all of the drop-in files read from the file system.
Added in version 252.
note that by default the systemd-sysusers.service unit file is set up to inherit the "passwd.hashed-password.root", "passwd.plaintext-password.root", "passwd.shell.root" and "sysusers.extra" credentials from the service manager. so when you're invoking a container with an unpopulated /etc/ for the first time, it's possible to configure the root user's password to be "systemd" like this:
# systemd-nspawn --image=... --set-credential=passwd.hashed-password.root:'$y$j9T$yAuRJu1o5HioZAGDYPU5d.$F64ni6J2y2nNQve90M/p0ZP0ECP/qqzipNyaY9fjGpC' ...
โ ๏ธ note again, bestie: the data specified in this credential is consulted only when creating an account for the first time. it may not be used for changing the password or shell of an account that already exists. read that twice. ๐
use mkpasswd(1) for generating UNIX password hashes from the command line. ๐
โญ EXIT STATUS โญ
on success, 0 is returned. otherwise you get a non-zero failure code. no in-between, she's binary like that. ๐
๐ฆ SEE ALSO ๐ฆ
systemd(1), sysusers.d(5), Users, Groups, UIDs and GIDs on systemd systems[2], systemd.exec(5), mkpasswd(1)
๐ธ NOTES ๐ธ
- UAPI.2 Discoverable Partitions Specification โ https://uapi-group.org/specifications/specs/discoverable_partitions_specification
- Users, Groups, UIDs and GIDs on systemd systems โ https://systemd.io/UIDS-GIDS
and that's the whole page, bestie!! you ate this. this was brought to you by systemd 262.1 โ mwah, slay, go make some users ๐ โจ๐
๐ฆ where this page comes from
- arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms