What do pty and tty mean?

why picture why · Dec 13, 2010 · Viewed 130.3k times · Source

I noticed there are many mentions of pty and tty in some opensource projects, could someone can tell me what do they mean and what is the difference between them? Thanks!

Answer

caf picture caf · Dec 13, 2010

A tty is a terminal (it stands for teletype - the original terminals used a line printer for output and a keyboard for input!). A terminal is a basically just a user interface device that uses text for input and output.

A pty is a pseudo-terminal - it's a software implementation that appears to the attached program like a terminal, but instead of communicating directly with a "real" terminal, it transfers the input and output to another program.

For example, when you ssh in to a machine and run ls, the ls command is sending its output to a pseudo-terminal, the other side of which is attached to the SSH daemon.