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=PATH is specified, the arguments on the command line are used instead of the configuration file PATH.
  • 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 at systemd-nspawn(1)'s switch of the same name. ๐Ÿ’ซ

Added in version 247.

  • --image-policy= policy โ€” takes an image policy string as argument, as per systemd.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 in sysusers.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 file PATH.

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 -n was 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 other sysusers.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 ๐ŸŒธ

  1. UAPI.2 Discoverable Partitions Specification โ€” https://uapi-group.org/specifications/specs/discoverable_partitions_specification
  2. 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