Linux – What Are Pseudo Terminals (pty/tty)?

linuxptyterminal

This might be really basic question but I want to understand it thoroughly.

  1. What is a pseudo terminal? (tty/pty)
  2. Why do we need them? How they got introduced and what was the need for it?
  3. Are they outdated? Do we not need them anymore? Is there anything that replaced them?
  4. Any useful use-case?

What I did:

  1. Read man pages – got some info but not the exact picture.
  2. Tried to read on them from Unix Network Programming by Richard Stevens.
    Got some info but not the why? part.

Best Answer

  1. A device that has the functions of a physical terminal without actually being one. Created by terminal emulators such as xterm. More detail is in the manpage pty(7).
  2. Traditionally, UNIX has a concept of a controlling terminal for a group of processes, and many I/O functions are built with terminals in mind. Pseudoterminals handle, for example, some control characters like ^C.
  3. They are not outdated and are used in many programs, including ssh.
  4. ssh.
Related Question