Use the machinectl
command like this:
machinectl shell <username>@ /usr/bin/systemctl --user list-units --type=service --quiet
Here is an example with the local account erikdev on my computer.
[root@laptop ~]# machinectl shell erikdev@ /usr/bin/systemctl --user list-units --type=service --quiet
Connected to the local host. Press ^] three times within 1s to exit session.
systemd-tmpfiles-setup.service loaded active exited Create User's Volatile Files and Directories
Connection to the local host terminated.
[root@laptop ~]#
I'm running Systemd 248 on a Fedora 34 Linux computer.
[root@laptop ~]# cat /etc/fedora-release
Fedora release 34 (Thirty Four)
[root@laptop ~]# machinectl --version
systemd 248 (v248.3-1.fc34)
+PAM +AUDIT +SELINUX -APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified
[root@laptop ~]#
It might be possible to use systemd-run
instead of machinectl
, but I didn't get that to work.