Search This Blog

Loading...

Tuesday, February 10, 2015

How to run multiple simultaneous X Window sessions

If you share your Linux desktop machine with other users, you may occasionally need to switch from 1 X session to another. For example, you are busy writing code or blogging, and your spouse walks up to you and asks to 'quickly' check her email. You can log out so that she can login using her own account. But, the current context of your work is lost, and you need to re-establish it when you resume.

A better way is to have her run a second simultaneous X session. The steps are as follows:

  1. Switch to a virtual terminal.
    By default, six virtual text terminals are available to you (Ctrl+Alt+F1 to F6). Press Control+Alt+F1 to go to virtual terminal 1.

  2. Login as her.

  3. Execute the following command:

    $ startx -- :1

    This starts another X session using the first free graphical console. By default, 6 X consoles are available (Ctrl+Alt+F7 to F12). Your own existing X session is Ctrl+Alt+F7. The next free X console is therefore Ctrl+Alt+F8.

    To switch from her X session to yours, and vice versa, press Ctrl+Alt+F7 and Ctrl+Alt+F8 respectively.

You may use the above procedure to create up to 5 additional X sessions (Ctrl+Alt+F8 to Ctrl+Alt+F12). For each additional X session, increment the console number in both step 1 and 3. For instance, switch to virtual terminal 2 (Control+Alt+F2) to execute the command startx -- :2.