XDG_RUNTIME_DIR is not set and /run/user/<UID> does not exist when using su or sudo to switch user

Solution Verified - Updated -

Issue

  • su - <user> or sudo -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.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content