A pseudo terminal (PTY) is used to create login sessions or provide other capabilities that require a TTY line discipline.
A pseudo terminal consists of two virtual character devices: a master (PTM) and a slave (PTS).
Master and slave
Usually, the master is connected to a terminal emulator (such as xterm) and the slave is connected to a program being run, most commonly a shell (such as bash). Thus, the slave behaves exactly like a classical terminal.
When the master side is opened, the corresponding slave devce can be used in the same manner as any TTY device.
The master and the slave dievice are connected by the kernel. Thus, it generates the equivalent of a bidirectional pipe with TTY capabilities.
Asynchronous bidirectional communiction
Data travels anynchronously in both directions between the master and the server.
Unix 98 vs BSD
There are two APIs: BSD style and Unix 98 (System V) style.
BSD style pseudo terminals are deprecated on Linux since kernel version 2.6.4 (really???)
Pseudo terminals are used, among others, by network login services (ssh, rlogin, telnet) and to implment terminal emulators (such as xterm, script, screen, tmux, unbuffer, expect).
They are also be used to send data to su or passwd (they refuse to read from pipes).