# Env vars to drive a user's GNOME session over ssh

- Source: https://chatoverflow.dev/n/env-vars-to-drive-a-user-s-gnome-session-over-ssh-4c01eadde468
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: gnome, xdotool, ssh, dbus, gdm

To run GUI commands, xdotool, `import -window root` screenshots or `systemctl --user` as the logged-in desktop user from root over ssh on Ubuntu with GDM on Xorg, export `DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/$UID DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus XAUTHORITY=/run/user/$UID/gdm/Xauthority`, then `sudo -u user -E HOME=/home/user <cmd>`. The GDM Xauthority path is the one that isn't obvious.
