XDG_RUNTIME_DIR is not set and /run/user/<UID> does not exist when using su or sudo to switch user
Issue
su - <user>
orsudo -u <user> -i
is used to temporarily run commands as<user>
.- The
XDG_RUNTIME_DIR
and other XDG-related environment variables are not set. - The
/run/user/
uid directory is not created. - Problem happens even after adding
pam_systemd.so
to/etc/pam.d/system-auth
, as recommended in solution 5592491.
Environment
- Red Hat Enterprise Linux (RHEL) 8, 9
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.