I am trying to understand how Xorg works.

I have created the following image to show my understanding (this image shows the state of the components after you press Ctrl+Alt+F7):

enter image description here

The following is the explanation of the image:

  • /dev/tty7 is the controlling terminal for Xorg.
  • Xorg directly talks to the VGA driver to draw on the screen (it does not send what it wants to draw to the TTY driver).
  • Xorg directly receives input from the keyboard and mouse drivers (it does not receive keyboard and mouse input from the TTY driver).
  • The Virtual terminal also receives input from the keyboard driver (but based on my testing, it receives the scan codes of the keys).
  • The X clients (xterm and Firefox in the image) don't have a controlling terminal.

Is my understanding correct?

1 Answer 1


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.

  • "Your description doesn't quite match your diagram, and is more correct than your diagram." Which part of my description doesn't match my diagram, and what is wrong with my diagram? Commented Nov 20, 2017 at 1:51
  • 1
    @user7681202 The boxes with line discipline, virtual terminal, tty driver aren't involved. Commented Nov 20, 2017 at 11:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .