[svlug] X Sessions

Akkana Peck akkana at shallowsky.com
Sat Nov 15 13:57:43 PST 2014


A few things to add to Rick's very complete explanations:

Scott DuBois writes:
> Ok, so I can execute commands in xterm which leads to being able to
> launch other programs as well i.e. ~$ kate & (launches kate) as X window
> and so on. So far so good, pretty much what I was looking for.
> 
> Had to open htop and filter for :1 to figure out how to kill the X
> session though. Seems /bin/sh is sending it to /etc/X11/xinit/xinitrc

If you've run X in a way that it only runs a single xterm, and no
window manager -- e.g. "startx xterm -- :1", though it sounds like
you may have gotten that xterm another way -- then exiting the xterm
(exit or Ctrl-D) will also exit the X server.

Or, to put it more generally, when you run startx you usually run
one program inside it; and when you exit that program, whatever it
is, X will also exit. Most often, that program running inside X
is a window manager or a desktop session (like gnome-session), but
it can be an xterm or anything else.

> Now, how would I launch an entire KDE interface?

I don't have KDE installed here, but I'd try:
startx startkde -- :1

At least, that used to work, many years ago.

Rick Moen writes:
> I can spot one complication right off the bat:  You're using a distro
> with the systemd init process.  [ ... ]
> I would _guess_ that a systemd-based system would default to starting
> the first X session on /dev/tty1, the second one on /dev/tty2, etc.
> I'm actually pretty sure about that guess, but someone else might be
> able to cross-check.

I'm on Debian sid which does seem to have switched to systemd by
default -- at least, apt shows it as installed and ps aux | grep systemd
shows quite a few processes.

On this system,. Ctrl-Alt-F1 gets me to my main X session (the one
I started from the first text console where I logged in, which
presumably was tty1). Ctrl-Alt-F2 gets me to a new text console
on /dev/tty2, and if I run startx -- :1 from there, Ctrl-Alt-F2
will get me to that second X session.

Some six or so years ago, long before systemd, when I was using a
second X session regularly, Ctrl-Alt-F1 always took me to the first
text console.  If I was running X, that console would show output
from the running X session (and no prompt, since X was running in
the foreground) and Ctrl-Alt-F7 took me to that X session.

If I wanted to run a second X session on :1, I had to do it from
/dev/tty2 via Ctrl-Alt-F2. No machination I ever found would let me
run an X :1 session from any tty other than tty2, and likewise for
:2 and tty3. I never understood the mechanism that was enforcing that,
but once I figured it out, starting additional X sessions became easy.

> I might, at this dramatic juncture in our narrative, recommend a handy
> little control called the ~/.xinitrc file to you.

I have long used .xinitrc anyway, since I run openbox as my window
manager. But it was particularly helpful when I needed to run a
second X serssion with different window manager settings from my
main desktop. (I needed this because I needed to take a lot of
screenshots for my book, and that was much easier if I used a simple
white background and window borders that looked more like an
ordinary user might expect and less like what I personally use.)

I had an alias:

alias secondx='startx $HOME/.xinitrc.screenshots -- :1'

then .xinitrc.screenshots was a little shell script file that ran
xsetroot -solid white, and then a window manager that was set up
with my screenshot theme.

Back then I had to Ctrl-Alt-F2 and log in to tty2 before I could
run secondx. Today, under systemd, I still have to run it from a
virtual console, but it can be Ctrl-Alt-F2 or Ctrl-Alt-F3 or
whichever, as long as I'm not trying to run it from inside an
existing X session, in which case it complains "X: user not
authorized to run the X server, aborting."

        ...Akkana




More information about the svlug mailing list