0

I'm using Linux console for years, but currently started thinking of how it actually works. Typing a command as a string and pressing Enter returns its output in the same terminal window.

Opening a new terminal window and executing tty shows the following result:

$ tty
/dev/pts/10

Man page on pty defines that:

A process that expects to be connected to a terminal, can open the slave end of a pseudoterminal and then be driven by a program that has opened the master end. Anything that is written on the master end is provided to the process on the slave end as though it was input typed on a terminal. [...] Conversely, anything that is written to the slave end of the pseudoterminal can be read by the process that is connected to the master end

My understanding:

The actual terminal window is connected to a slave /dev/pts/10 and all the input I type into the terminal window is written on the slave end and then read on the master end. A process connected to the master end knows what to do with all the strings user type, executes them and write commands results on the master end which are then read on the slave end and displayed in the terminal window.

The question:

What is the process connected to the master end which knows how to execute commands which users type as strings?

4
  • 1
    The process that knows how to execute commands is named "shell", and it runs on /dev/pts/10, not the master. What runs on the master (/dev/ptmx, I believe) is a terminal emulator like xterm or a remote shell like sshd. Jun 15 at 23:12
  • @berndbausch Good point, thanks!
    – Some Name
    Jun 16 at 2:24
  • @berndbausch Is there a way to understand what process is attached for an arbitrary /dev/pts/x?
    – Some Name
    Jun 16 at 2:25
  • 1
    Attached to pts or ptm? The former: ps -t pts/x. The latter I can't tell. There seems to be a single /dev/ptmx (literally with an x, not a number), and I don't know if and how the master process of /dev/pts/x can be found. Jun 16 at 5:17