Chad Clark's Open Journal : 2007-09-03

Historical Entries   Recent Entries   About The Author   RSS  

September 03, 2007 :
1) How to create a second X11 virtual console in Linux.

N.B. This was tested using Fedora Core 6.

Normally under Linux you can press Alt and F1 through F6 to get a text
console.  When X11 is running on the system you can press Alt-F7 to get to
the GUI.

FreeBSD use Ctrl-Alt-F1 and I still tend to use that on Linux.  I didn't
realize (or maybe remember) that to switch away from a X11 virtual console
you might have to use Ctrl-Alt-F*.  Possibly X11 or your window manager is
grabbing the plain Alt-F* key chord.

Aside:

  Years ago I did not run X11 because of the resources required.  When your
  compile jobs take long enough to go make, bake, and eat a pizza you might
  care that X11 is overhead and you could be getting faster compiles.
  
  It was not unusual for me to have 3 or 4 virtual consoles in use at the
  same time.  Like normal I also had jobs suspended on multiple consoles.
  
  When people saw me working they often expressed wonder at why I would do
  such a thing.  It's simple.  I can have a man page, an editor, a file
  listing, and source code grep (sending the output to less) all ready for
  me to jump between them as needed.
  
  I still get amazed when I see coworkers open vi, page down, move the cursor
  edit a line to add print statement, close vi, run the program, open the
  file again, page down, move the cursor, edit the print statement, ...
  
  They close the editor between test runs!  I'm not making this up.  We are
  late into the age of the xterm.  Do the test run in another window or
  suspend your editor.  (I'm ignoring being able to compile your program
  and run commands without even leaving emacs.)

For the most part xterm windows and virtual desktops have replaced virtual
consoles.  Sometimes though you have a program that wants to run full-screen
and not in a window on your desktop.  Here is how to run that GUI program
or any other program using a spare virtual console.

Create a new xhost config file for a new display number.  I used the number
one because zero is the regular display.  Whatever number you pick needs to
be in the name of the file as the * in /etc/X*.hosts.

  [chad@lorax ~]$ echo $DISPLAY 
  :0.0
  
  [chad@lorax ~]$ cat /etc/X1.hosts
  local:

Now start X using the new display number and specifying a virtual console
number.  Normally 7 is where X11 runs and 1 through 6 are consoles.  To use
8 use "vt8" like so:

  [chad@lorax ~]$ Xorg :1 vt8

The screen will change to black.  You might see a nVidia splash logo or
similar.  There should be a cursor you can move with the mouse but clicking
has no effect.

Press Ctrl-Alt-F7 to get back to your original screen.  Set the DISPLAY
environment variable and run a test command.

  [chad@lorax ~]$ DISPLAY=:1 xeyes

Press Ctrl-Alt-F8 to switch to the second virtual console.  Notice the eyes
in the top left corner watching the mouse pointer.  Press Ctrl-Alt-F7 to
get back to your command line and stop xeyes with Ctrl-C.

Now try running something like a window manager.

  [chad@lorax ~]$ DISPLAY=:1 startfluxbox

Switch to it and see that you have a second window manager running on one
machine at the same time.



Historical Entries   Recent Entries   About The Author   RSS