My xorg session is on tty1 and if I want to issue a command from tty (because I cannot do it from xorg session for some reasons), I press Ctrl+Alt+F2, for example, and type a command. But I cannot start graphical applications from any tty except first since there is no xorg session in it. Then I am curious how can I switch to tty1 where xorg session is running and back to the session?
Linux – How to Switch Between TTY and Xorg Session
linuxttyxorg
Related Solutions
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.
Your description doesn't quite match your diagram, and is more correct than your diagram.
The X server does not use the tty driver for either input or output. It reads inputs directly from the drivers for the various input devices and sends output directly to the graphics card drivers.
You can list the input devices with xinput
and then get further information with xinput list-props
. For example:
$ xinput | tail -n 1
↳ USB Keyboard id=10 [slave keyboard (3)]
$ xinput list-props 10 | tail -n 1
Device Node (263): "/dev/input/event2"
You can see that my X server obtains input from my USB keyboard by reading from /dev/input/event2
.
For output, I don't know if there's a similar user-level tool. xrandr --listproviders
lists the graphics drivers that are in use or available, but does not list /dev
entries. You can see which graphics device the X server has open with lsof -p$(pgrep Xorg)
or less /var/log/Xorg.0.log
.
The concept of controlling terminal was designed for text mode sessions. An X server may or may not have a controlling terminal depending on how it was launched. An X program that was started from a GUI menu typically doesn't have a controlling terminal, because the window manager doesn't have one. An X program started from a shell running in a terminal does have that terminal as a controlling terminal.
Best Answer
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: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 trystartx
.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.).