How to execute "systemctl --user" as a different user

Solution Verified - Updated -

Issue

  • Trying to execute systemctl --user as a different user fails with Failed to connect to bus: No such file or directory

    # systemctl --user list-units
    Failed to connect to bus: No such file or directory
    
  • Trying to execute systemctl --user after setting the environment variable XDG_RUNTIME_DIR for the target user fails with Failed to connect to bus: Permission denied

    # id -u user1
    1000
    # export XDG_RUNTIME_DIR=/run/user/1000/bus
    # systemctl --user list-units
    Failed to connect to bus: Permission denied
    

Environment

  • Red Hat Enterprise Linux 8
    • systemd (user instance)
    • sudo / su

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In