Starting a New X Server

This is one of those posts that is mostly for me, so the next time I need to do this I don’t have to spend 30 minutes googling obscure config file formats. (Incidentally, I had to google and muck with styles for at least 30 minutes to figure out how to keep wordpress from mangling my code snippets.)

I sometimes find it useful to start an extra X server to run a particular application. Full-screen games are a good example. Ordinarily, a full-screen game grabs the display and there is no way to switch back to the desktop without exiting the game completely. When run in its own X server though, it is easy to switch between servers. The following shell script shows how to do this:



if ! xauth list "$display" | grep "$display " >/dev/null 2>&1; then
    xauth add $display . `mcookie`

xinit /usr/bin/xterm -- $display -auth $authfile -nolisten tcp

if [ -n "$removelist" ] ; then
    xauth remove $removelist

This script will start a new X server on the next available virtual terminal (normally vt8) using display :1 and launch an xterm. Toggle between the servers using ctrl-alt-F7 and ctrl-alt-F8. When the xterm exits, so does the X server.

If you try to run this code on a Debian-based system, though, you will get the following error:

X: user not authorized to run the X server, aborting.
xinit:  Server error.

I found this out the hard way when I started using ubuntu. This is because Debian uses a wrapper to start the X server, which enforces tighter security constraints by default. To get this to work, you will need to edit the /etc/X11/Xwrapper.config file, and change this line:


to this:


Check the man page for Xwrapper.config for more options; there aren’t very many. Personally, I don’t consider this a security risk for a single-user home system.

Tags: ,

Leave a Reply

Copyright © 2017 All Rights Reserved.
No computers were harmed in the 0.925 seconds it took to produce this page.

Designed/Developed by Lloyd Armbrust & hot, fresh, coffee.