When using lightdm I can switch to another user by executing
dm-tool switch-to-user. Is there a way that doesn't depend on the display manager? If not, what would be the equivalent command for the other display managers:
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Is there a way that doesn't depend on the display manager?
You're asking for a command-line / run program solution.
Given my experience with xdm, gxm, lightdm and how all this works, I think there's no perfect one-size-fits-all answer. The reason is: providing actual user isolation requires the display manager to closely manage vt switch.
That said, on a simple and/or old-fashioned display manager, I have in the past considered a solution that should work.
Basically, one can use
chvt with argument the content of
XDG_VTNR environment variable of target user session process. The effect is similar to pressing
Ctrl-Alt-Fn key combination, with
n the number you provide to
chvt. This is considered in comments on xorg - Switching between two opened X sessions without reauthenticating - Ask Ubuntu.
Still, you're on your own to get that number. Either have a process run by root which snoops environment of processes of target user, or have users advertise this number when they log in, through a known location (e.g.
~/.myvtnr, assuming one user has nos more than one X session at a time, which is not always true, users may have several X sessions, including nested sessions using
If not, what would be the equivalent command for the other display managers:
On Ubuntu 12.04 running gdm, here it what worked for me:
dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.DisplayManager $XDG_SEAT_PATH org.freedesktop.DisplayManager.Seat.SwitchToUser string:otheruserlogin string:anywordseemsignored . Replace
otheruserlogin with a real user login.
XDG_SEAT_PATH is not set (e.g.
echo $XDG_SEAT_PATH does not provide any output), then you can first use:
export XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0 then retry.
Does it work for you with Ubuntu 18.04 with gdm? With other display managers? Please report with details. It may help others in the future (including you and me :-).