How to start X for a second user on system without killing the first one?

Hi, LinuxConfig people!

I’m using Debian Buster with LXQt desktop environment (DE) and SDDM as session starter. I have two users. I want to start a second X.org session for user2 when I am already logged in X with user1.

This is what I had researched but had failed so far:

  1. Enter X as regularly with user1
  2. Go to tty2, login as user2 and type:
    $ startx -- :1
  3. X starts correctly in tty2 and I can enter the session

The problem shows when I want to go back to tty7 (Debian convention, no tty1) because user1 has logged out and all my work is lost.

So, what do I have to do? Where does the problem lies? Somewhere with policykit configuration, or maybe I should change to LightDM, or do I type some other startx option that I am not aware? Is this possible with my current configuration?

My intention is to have user1/DE1 for personal stuff, and user2/DE2 for work. So I can switch between them no matter which hour it is.

I previously said DE1 and DE2 because in the future I will install other DE than LXQt… maybe Bungie, nad still have the ability to switch users. For the moment both users log into LXQt.

Hi LobaLuna,

From what I have gathered, you could test this configuration by executing startx (as user2) without any option, which should start the new graphical session in the next free tty - and maybe redirecting the output for debug purposes:

$ startx &> ~/2ndxsession.log

Also, you should check the logs generated by the first graphical session to see why user1 is logged out.

Hi, @sandmann!

You are right that I can start another session for a second user easily. However, the debug log for debugging purposes is no useful. Here it is:

X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.9.0-8-amd64 x86_64 Debian
Current Operating System: Linux ZAFIRO 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.19.0-6-amd64 root=UUID=99999999999999999999999999999 ro quiet
Build Date: 05 March 2019  08:11:12PM
xorg-server 2:1.20.4-1 (https://www.debian.org/support) 
Current version of pixman: 0.36.0
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/home/asurdaria/.local/share/xorg/Xorg.1.log", Time: Tue Oct 15 19:28:48 2019
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
xf86EnableIOPorts: failed to set IOPL for I/O (Operation not permitted)
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Warning:          Symbol map for key <RALT> redefined
>                   Using last definition for conflicting fields
Errors from xkbcomp are not fatal to the X server
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Warning:          Symbol map for key <RALT> redefined
>                   Using last definition for conflicting fields
Errors from xkbcomp are not fatal to the X server
(II) AIGLX: Suspending AIGLX clients for VT switch
xinit: connection to X server lost

waiting for X server to shut down (II) Server terminated successfully (0). Closing log file.

I have no clue looking at it for what makes my first session to shutdown. I just changed the UUID for privacy concerns.

Hi LobaLuna,

Do you see any related messages in your first graphical session’s logs? It should be somewhere in your first user’s .local/share/X11 or .local/share/xorg directory.

Hello,
maybe, u can also check that your xorg packages “are OK”, run

sudo debsums|grep -i xorg|grep FAILED

And If some result is returned, you might have to re-install the relative file package.

Found a potential solution online, might be of some help to you.

Xargs supports an option to specify the number of processes that you want to run simultaneously.
seq 1 3 | xargs -I{} -n 1 -P 3 wget https://storage.googleapis.com/test-bucket-sarath/junkfile{}

seq command will simply give 1, 2, and 3 as output in three lines. Which is then passed to xargs as input using the standard Linux pipe. We have used the option -I in xargs to remove the space character that generally gets added towards the end of our command.

Without -I{} and the last junkfile{}, xargs would construct our command with the file name of “junkfile 1, junkfile 2 etc” (we needed to remove the space), rather than junkfile1, junkfile2 and so on.

You can quickly confirm that 3 processes are running in parallel (as we passed -P 3), using another terminal and counting the number of wget processes.

@liam.nillson Hi!
You are very kind, but I do not see how is this related to Xorg or X11. That is what here I am dealing with. To open a second Xorg or X11 session without closing the first one, just as in old day it was possible.

@fabek Hi!
I ran the command as you suggested, and fortunately everything is OK. However, the questions remains… Thanks anyway.

@sandmann Hi!
I checked as you indicated. yes, there are errors in .xsession-errors and some lines in ~/.local/share/xorg/Xorg.1.log

There are too many lines. Do I post them here? If you can help me interpreting, it’ll be alright!

Hi LobaLuna,

Sure, post the messages. Upload only entries that have the date of the last session, I guess the issue is the same on all forced logouts.

Hi, sandmann!
Thanks.

Then I post first how a regular session is started (Debian Buster uses xfwm4):

root       798  0.0  0.1 140400 13936 ?        Ssl  21:27   0:00 /usr/bin/sddm
root       844  2.8  0.7 1196320 93360 tty7    Ssl+ 21:27   2:25  \_ /usr/lib/xorg/Xorg -nolisten tcp -auth /var/run/sddm/{b0328497-7b72-4001-814c-ac3d3dc609d2} -background none -noreset -disp
root      1129  0.0  0.1  59520 13384 ?        S    21:28   0:00  \_ /usr/lib/x86_64-linux-gnu/sddm/sddm-helper --socket /tmp/sddm-autheef7db27-4089-4bcb-9c3d-b6ebfe8c64a7 --id 1 --start start
arpe      1148  0.0  0.2 270252 30636 ?        Sl   21:28   0:00      \_ lxqt-session
arpe      1202  0.0  0.0   5840   468 ?        Ss   21:28   0:00          \_ /usr/bin/ssh-agent /usr/bin/im-launch startlxqt
arpe      1309  0.3  0.3 264160 36592 ?        Sl   21:28   0:18          \_ /usr/bin/xfwm4
arpe      1344  0.0  0.8 2034136 98212 ?       Sl   21:28   0:03          \_ /usr/bin/pcmanfm-qt --desktop --profile=lxqt
arpe      1345  0.0  0.2 343800 30972 ?        Sl   21:28   0:00          \_ /usr/bin/lxqt-globalkeysd
arpe      1346  0.0  0.6 1245236 79428 ?       Sl   21:28   0:00          \_ /usr/bin/lxqt-notificationd
arpe      1347  0.1  0.8 1608320 98392 ?       Sl   21:28   0:07          \_ /usr/bin/lxqt-panel
arpe      1348  0.0  0.2 422900 33004 ?        Sl   21:28   0:00          \_ /usr/bin/lxqt-policykit-agent
arpe      1349  0.0  0.3 277288 41180 ?        Sl   21:28   0:01          \_ /usr/bin/lxqt-runner
arpe      1535  0.0  0.2 272368 35052 ?        Sl   21:28   0:00          \_ /usr/bin/lxqt-powermanagement

And then this is the output of the first session that crashed after initiating the second one, but then reopened again.

(0x7ffd4772de50) Warning: The X11 connection broke: I/O error (code 1)
XIO:  fatal IO error 25 (Inappropriate ioctl for device) on X server ":0"
      after 65844 requests (65844 known processed) with 0 events remaining.
parcellite: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.
(0x7ffe43ae7330) Warning: The X11 connection broke: I/O error (code 1)
XIO:  fatal IO error 25 (Inappropriate ioctl for device) on X server ":0"
      after 856 requests (856 known processed) with 0 events remaining.
Not setting scale factors. Using predefined QT_SCREEN_SCALE_FACTORS= eDP=1
Invalid MIT-MAGIC-COOKIE-1 keyqt.qpa.screen: QXcbConnection: Could not connect to display :0
Could not connect to any X display.
Xsession: X session started for arpe at Tue 29 Oct 2019 11:03:18 PM CST
dbus-update-activation-environment: setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment: setting DISPLAY=:0
dbus-update-activation-environment: setting XAUTHORITY=/home/arpe/.Xauthority
localuser:arpe being added to access control list
dbus-update-activation-environment: setting GTK_MODULES=gail:atk-bridge
dbus-update-activation-environment: setting QT_ACCESSIBILITY=1
!: 1: !: Syntax error: Unterminated quoted string
isPrimaryInstance
(0x7ffe95d8d2d0) Debug: New PolkitAgentListener  0x5571a0a266a0
(0x7ffe95d8d2d0) Debug: Adding new listener  PolkitQt1::Agent::Listener(0x7ffe95d8d2e0) for  0x5571a0a266a0
Flag 0x0001, status 256, EXIT 1 STAT 1
(0x7ffdaa4140e0) Debug: systemd: "CanHibernate" = "yes"
(0x7ffdaa4140e0) Debug: systemd: "CanSuspend" = "yes"
(0x7ffebef85000) Debug: systemd: "CanReboot" = "yes"
(0x7ffebef85000) Debug: systemd: "CanPowerOff" = "yes"
Flag 0x0001, status 256, EXIT 1 STAT 1
size of cached file QSize(1024, 768) , requiredSize: QSize(1366, 768)
no cached wallpaper. generate a new one!
size of original image QSize(1366, 768)
(0x7ffde4c3a840) Debug: ()
Daemon is already running.
(0x7ffde4c3a840) Debug: WinIdChange 1200008 handle QWidgetWindow(0x556d25e5fb40, name="LXQtPanel panel1Window") QScreen(0x7f07a40047e0, name="eDP")
(0x7ffde4c3a840) Debug: Systray started
Setting QT_SCREEN_SCALE_FACTORS= "eDP=1"
Error unsetting QT_QPA_PLATFORMTHEME vble
(0x7ffcf5d0a3a0) Debug: BatteryChanged discharging: false chargeLevel: 97.8311 actionTime: QTime(Invalid)
(0x7ffcf5d0a3a0) Debug: Inhibit got: 26
(0x7ffcf5d0a3a0) Debug: Starting idlenesswatcher
(0x7ffde4c3a840) Debug: Error on DBus request: QDBusError("org.freedesktop.DBus.Error.UnknownProperty", "Property org.kde.StatusNotifierItem.IconThemePath was not found in object /StatusNotifierItem")
(0x7ffde4c3a840) Warning: e[31mvoid DBusMenuImporter::slotGetLayoutFinished(QDBusPendingCallWatcher*)e[0m: "No such object path '/NO_DBUSMENU'"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/meteo_qt/meteo_qt.py", line 1383, in done
    self.overviewcity()
  File "/usr/lib/python3/dist-packages/meteo_qt/meteo_qt.py", line 325, in overviewcity
    rise_str = self.utc('Sunrise', 'weatherdata')
  File "/usr/lib/python3/dist-packages/meteo_qt/meteo_qt.py", line 445, in utc
    self.weatherDataDico[rise_set].split('T')[1].split(':')
AttributeError: 'NoneType' object has no attribute 'split'
(0x7ffde4c3a840) Debug: Service "org.freedesktop.StatusNotifierItem-13526-1" unregistered
(0x7ffde4c3a840) Debug: Error on DBus request: QDBusError("org.freedesktop.DBus.Error.NoReply", "Message recipient disconnected from message bus without replying")
[Notice] Started
Update for linux-x64-prod-v1.7.0 is not available
Down: Everything Downloaded| Up: Everything Uploaded, status is CONNECTING
Down: Everything Downloaded| Up: Everything Uploaded, status is SCANNING
Down: Everything Downloaded| Up: Everything Uploaded, status is READY
(0x7ffde4c3a840) Debug: Error on DBus request: QDBusError("org.freedesktop.DBus.Error.InvalidArgs", "No such property “ToolTip”")
(0x7ffde4c3a840) Debug: Error on DBus request: QDBusError("org.freedesktop.DBus.Error.InvalidArgs", "No such property “OverlayIconName”")
(0x7ffde4c3a840) Debug: Error on DBus request: QDBusError("org.freedesktop.DBus.Error.InvalidArgs", "No such property “OverlayIconPixmap”")
(0x7ffde4c3a840) Debug: Error on DBus request: QDBusError("org.freedesktop.DBus.Error.InvalidArgs", "No such property “AttentionIconPixmap”")
[Notice] X11 error: type: 0, serial: 737, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 739, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 741, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 743, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Warning] Cannot grab shortcut 'Control+F5'
[Notice] X11 error: type: 0, serial: 753, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 755, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 757, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 759, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Warning] Cannot grab shortcut 'Control+F6'
[Notice] X11 error: type: 0, serial: 769, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 771, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 773, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 775, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Warning] Cannot grab shortcut 'Control+F7'
[Notice] X11 error: type: 0, serial: 785, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 787, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 789, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 791, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Warning] Cannot grab shortcut 'Control+F8'
[Notice] X11 error: type: 0, serial: 801, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 803, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 805, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 807, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Warning] Cannot grab shortcut 'Control+F9'
[Notice] X11 error: type: 0, serial: 817, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 819, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 821, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 823, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Warning] Cannot grab shortcut 'Control+F10'
[Notice] X11 error: type: 0, serial: 833, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 835, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 837, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 839, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Warning] Cannot grab shortcut 'Control+F11'
[Notice] X11 error: type: 0, serial: 849, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 851, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 853, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Notice] X11 error: type: 0, serial: 855, error_code: 10 'BadAccess (attempt to access private resource denied)', request_code: 33 (GrabKey), minor_code: 0, resourceid: 1701
[Warning] Cannot grab shortcut 'Control+F12'
(0x7ffde4c3a840) Debug: execAction "/usr/share/applications/pcmanfm-qt.desktop"
(0x7ffde4c3a840) Warning: QXcbConnection: XCB error: 3 (BadWindow), sequence: 2611, resource id: 39845910, major code: 18 (ChangeProperty), minor code: 0

Hi LobaLuna,

These entries are interesting. Do you have any related logs in /var/log? Something like Xorg.0.log, with entries at the same time?

Also, upon successful login on the second session, which display are you connected to? You can query that on the terminal with who.

Hi, sandmann

Sorry for the delay. Since my X.org.log.old is bigger than the post limit. Here’s my log file:
Xorg log: failing when switching to new VT

To test purposes, I always connect to VT4, display 0

Sorry, I had to run earlier, and submitted a response before ever finishing a sentence. So, I’m just passing through, and thought I might provide some potential insight. From my super quick scan of your logs, it appears the issue is that A) even though you’re starting from VT(n), by not explicitly telling xinit (startx is just a wrapper that dumbs down xinit… to actually start a new X on VT4 using DISPLAY:1, this is because rather than acting on VT4, startx if configured to default to :0 on VT7

What you want is essentially a single head, single seat, multiscreen xorg setup. It shouldn’t take much more than modifying the commands properly, but if you want to automate this, I would definitely create an additional config file for your second X server.

FYI: In case any of you aren’t aware. The display number is synonymous with the Xorg server number, so DISPLAY=:0 on vt7 is X:0, and has associated Xorg.0.log (and potentially Xorg.0.conf), and your second X server, on vt4 (or one of your choice) will be DISPLAY=:1

So, I boot up, systemd obnoxiously sets up everything fine and dandy, and I get my login screen (I don’t use a display manager, but lightdm, and sddm can both handle more complexity than a single X on vt7, xorg was designed as multi-user from the start! Just a matter of fighting their configs)

I’m logged in, and reach my login shell. From there, I start my first X server with a simple “xinit” my ~/.initrc runs, and I get a minimal set-up, and a fancy tmuxed to hell xterm! This is where I start my second screen, and if it doesn’t work as intended, all my shell’s die!!! Muhahah.
from my vt7, X=:0, I run “xinit /usr/bin/xterm – :1 vt4”

take note of the double -hyphens-, they separate your desired programs to run from server configuration, you simply need to declare an unused DISPLAY=:(n) and choose your VT(n)

The reason I run this from within a terminal on my first DISPLAY=:0? No need to hop over to the other VT first, it will open it for you if no errors drop, and by logging out, and exiting the VT7 xterm session, both sessions end… aaaaand it ensure’s both persist between changes, since killing the first would kill my second :P.

I definitely suggest you use init over startx. I’m unsure why, but I’ve always had to append the startx command with sudo when changing VTs like this, which drops you into a root session, not what I want!

“sudo startx xterm – :6.0 vt3”

I’m assuming I could add my user to a group with access privileges, I just can’t be bothered with xinit works the same.

If you want to use this regularly, can prepare an alternative xorg configuration file for xinit to set up your second screen.

“xinit /usr/bin/xterm – :1 vt4 --config /path/to/configfile.conf”

And if you don;t want to use the same user for both logins, you can make changes to the xinit commands, or to the config files, accordingly.

Let me know if this solves your issue. If not, maybe I misunderstand your use-case, this works for me fine!

There’s some crazy things you can do with X server, if you’re willing to beat it into submission, check out xorg.conf, multiseat, multihead, etc. Those are different use-cases, (multiseat = multiple users, using the same PC at the same time, separate screens and kb/mouse, multihead is single seated, but with many screens under the same Xserver, so the result of xrandr and whatnot), if you require any more fine tuning than above, these may not be the same thing you want, but if you examine the configurations, you’ll see that they adapt to your use easily.

1 Like

Joseph_MoDo,

I’m sorry for the delay. I have too much work these days.

Your response is utterly complete. Thank you very much! I also learned a lot! Just because if that, it is so worth keeping it.

I will try what you suggested, and I’ll report back.