What matters is actually not what console you run the command from, but that you tell the program to connect to the still-existing X display. To do this, set the DISPLAY
variable and restart Compiz from a standard terminal. Depending on your distribution and configuration, you may need to set XAUTHORITY
as well. Switch to tty1 and type:
$ export DISPLAY=:0
$ compiz --replace &
The display may be different on your machine. Use who
to find yours:
$ who
you tty1 [time] < This is you from tty1.
you :0 [time] (:0) < This is you from tty7.
^^ ^^
This is your display on tty7
Note: you must be logged in as yourself on tty7 (graphically). Fortunately, when Compiz crashes, you are not disconnected from tty7 (even though you can't do much).
how can I switch to tty1 where xorg session is running and back to the session?
Because X is running on tty1, but not on tty2. A tty is a "virtual terminal", meaning it is supposed to represent an actual physical screen and keyboard, etc. The terminals are all on simultaneously, but since you only have enough hardware to interface with one at a time, that's what you get.
You can in fact run multiple X sessions on different ttys and switch between them. You need a valid ~/.xinit
or ~/.Xclients
first. If you don't, for illustration:
echo -e "#!/bin/sh\n mwm" > ~/.xinit
chmod u+x ~/.xinit
Check first that mwm
exists by trying it from the command line. As long as it doesn't say "command not found" you're good. Now from tty2 try startx
.
If there isn't a display manager doing something totalitarian, you should get a plain black window with a big X mouse cursor. Left clicking should give a crude looking menu from which you can now "Quit"; but before that CtrlAltF1 will take you to the other X session on tty1 (and F2 gets you back, etc.).
Best Answer
Usually the X server runs on the first tty that was available when it started. (Under Linux, the X server does not run on the same console where you ran
startx
.) Many distributions set up 6 text mode consoles, so the first X server ends up on tty7 (Ctrl+Alt+F7). If there's a second X server, it ends up on tty8 (Ctrl+Alt+F7), etc. You can also use Alt+SysRq to return to the previous console (this only works from a text mode console, not from X).In principle, you should be able to run as many X servers as you have memory for. (Well, that and I think by default the maximum number of virtual consoles is 63.) However, video drivers sometimes have bugs. They're rather complex beasts, and it doesn't help that the hardware manufacturers rarely give out detailed enough specs to driver writers. Depending on your exact video card model and driver version, there may be bugs. Running multiple X servers at the same time is likely to have undergone little testing, and may well have been considered an unnecessary burden.
There's rarely any point in running multiple X servers on the same machine as the same user. (The main exception that comes to mind is if you're testing something.) If you want to switch between independent sets of windows on the same console in the same desktop environment, you can use virtual desktops, known variously as workspaces, desks, tags, etc. Most window manager and desktop environments support multiple virtual desktops. There's no standard interface: each has its own key and mouse bindings to switch between desktops, and its own graphical artifacts. However there's a common kind of visual widget: look for a small panel that represents a rectangular grid showing miniatures of your windows.