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.
  • I think so, too, especially if no specialized issues like openpty/forkpty arise here.
    – thiton
    Sep 20, 2011 at 18:31
  • Tried to flag it for migration, but Linux/Unix is not a valid migration target. Trying gradient descent, Super User is already a slightly better target than this site, and maybe they can route it to an even better site.
    – thiton
    Sep 20, 2011 at 19:25
  • 17
    This is a pretty good overview: linusakesson.net/programming/tty/index.php
    – nos
    Sep 20, 2011 at 20:00
  • @nos : wow! Thats an awesome link. The thing that I was looking for. Thanks a ton :)
    – hari
    Sep 20, 2011 at 20:06
  • 1
    Chapter 62 and Chapter 64 of The Linux Programming Interface may be helpful
    – zjk
    Feb 15, 2016 at 11:00

3 Answers 3


What is a pseudo terminal? (tty/pty)

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).

Why do we need them? How they got introduced and what was the need for it?

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.

Are they outdated? Do we not need them anymore? Is there anything that replaced them?

They are not outdated and are used in many programs, including ssh.

Any useful use-case?


  • 3
    Thanks @thiton. Can you please elaborate on your example of ssh? How does it use pty/tty? How does master/slave role play in ssh?
    – hari
    Sep 20, 2011 at 18:17
  • 6
    ssh allocates a pty for the shell it creates. The shell is connected to the slave end and thereby can rely on all the capabilities of a normal terminal (e.g. termcap if I remember correctly), and the ssh daemon connects to the master end and sends and receives its input there.
    – thiton
    Sep 20, 2011 at 18:24

The answer is in the name -- "Pseudo" meaning "not genuine but having the appearance of".

With the first terminals, there was always a piece of hardware attached with associated device, be it display hardware or a serial port.

With xwindows, telnet and ssh, there came a need for software "Pseudo devices" to do the job of standing in for display hardware. They are "Pseudo Terminals" ... software that emulates Terminal hardware, handling input and output in the same way a physical device would so that the software connected is not aware there's not a real device attached.

  • 1
    Because now we have many applications which need to access same piece of hardware, every app is using the hardware via "pseudo" terminal?
    – hari
    Sep 20, 2011 at 18:15
  • I expanded the answer a bit -- hope it clarifiies.
    – gview
    Sep 20, 2011 at 18:29
  • No, we just don't actually have that kind of hardware around anymore. xterm emulates a classic terminal, that's all.
    – thiton
    Sep 20, 2011 at 18:29
  • @thiton: When you say emulates, thats the software part, isn't it?
    – hari
    Sep 20, 2011 at 18:48
  • 1
    So using the word "terminal" in UNIX context today is actually wrong? Because everything is a "pseudo-terminal" ?
    – A. Sallai
    Jun 8, 2017 at 7:29

Pseudo-terminals are emulators for serial lines. They provide endpoints for telnet, ssh, and xterm shells.

  • 2
    And they're ancient relics (really, shells/text applications are still interacting over a device that emulates a tele-type writer over a serial line like they worked 40 years ago...) We still need them because there is no replacement :-(
    – nos
    Sep 20, 2011 at 17:55
  • Well, if you consider the terminal, I don't think you need much more than a stream of letters comming and going... Sep 20, 2011 at 17:59
  • 5
    @Diego Sevilla The original unix inventor did away with tty/ptys in Plan 9 , and there a terminal pretty much does just use a stream of in/out data. But in *nix, the ttys are still around and used by consoles and terminal emulators to e.g. control terminal size, flow control, line buffering, special key events, and other stuff.
    – nos
    Sep 20, 2011 at 18:06
  • 7
    @nos: It turns out they're not the ancient relics we're lead to believe. Trying to do without them in Windows is rather painful in the end. The use of powershell remoting is hampered by one thing: interactive console programs don't work and can't be fixed to work right. There is no possibility of a reasonable text editor like either DOS EDIT or vi.
    – Joshua
    Dec 15, 2015 at 17:43
  • 2
    @Joshua Another evidence to the contrary is the original designers of Unix created the Plan 9 OS, where they completely did away with ttys, yet they achieved remoting in that manner (and much more) just fine.
    – nos
    Dec 15, 2015 at 19:23

You must log in to answer this question.

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