List users¶
Source · io.systemd.UserDatabase · systemd v257+ · Unprivileged
userdbctl user in Go. systemd-userdbd's multiplexer merges every user
source on the system (/etc/passwd, systemd-homed, NSS, ...) and, with
Varlink's more flag, streams one reply per user. There is no D-Bus equivalent.
Run it¶
Output (illustrative)
NAME UID DISPOSITION HOME REAL NAME
root 0 intrinsic /root Super User
nobody 65534 intrinsic / Kernel Overflow User
systemd-resolve 991 system / systemd Resolver
ross 1000 regular /home/ross Ross Edman
The code¶
How it works¶
- Supports-more.
GetUserRecordis annotated[Supports 'more' flag], so the package has bothGetUserRecord(one reply, used with-user) andGetUserRecordMore(aniter.Seq2of every record). Service: "io.systemd.Multiplexer"is required: it tells userdbd to query all sources.- The record is JSON.
Recordisjson.RawMessageholding a full JSON user record; the example decodes a few fields into its own struct. varlink.Ptrbuilds the optionalUserNamefilter.