Linux

Tech Tip: Run two X sessions simultaneously in Linux

Learn how to run two X sessions at the same time.

With Linux, most things are possible, including running two graphical desktops at the same time. With OS X or Windows, if you want another user to be able to use a desktop or if you want to use two different GUIs at the same time, you need to use "user switching," which temporarily suspends one desktop and logs into another.

While this is fine for most applications, there can be times when you need to run both GNOME and KDE (or any other desktop system you like) at the same time. You can easily accomplish this on Linux using XFree86.

When you start an X session, either from the command line or by logging in using a display manager such as KDM or GDM, X typically starts on pty7. This allows you to switch to pty1 through pty6 by pressing [Ctrl][Alt][F1] through [Ctrl][Alt][F6] respectively, and you can switch back to X using [Ctrl][Alt][F7].

You can extend this by switching to the command line and starting another X session. Execute the following:

$ startx -- :1

This command launches a second instance of X on the next available pty, which would be pty8. By default, X starts with session :0, so tell startx to start session :1.

You can access the new X session by pressing [Ctrl][Alt][F8]. In addition, you can switch between the first and second X sessions by pressing [Ctrl][Alt][F7] to get to the first session and pressing [Ctrl][Alt][F8] to get to the second session.

You can do this more than once, but keep in mind that memory and CPU speed may drag down the overall responsiveness of the system.

Likewise, you can also start a program on one session and have it appear on the other if you start it from an xterm running on the first session. Use the following:

$ DISPLAY=:1 gkrellm &

This starts GKrellM on the second instance of X by giving it the DISPLAY environment variable.

0 comments

Editor's Picks