In some operating systems, including Unix, a pseudoterminal, pseudotty, or PTY is a pair of pseudo-devices, one of which, the slave, emulates a hardware text terminal device, the other of which, the master, provides the means by which a terminal emulator process controls the slave.
The role of the terminal emulator process is:
- to interact with the user.
- to feed text input to the master pseudo-device for use by the shell (such as bash), which is connected to the slave pseudo-device.
- to read text output from the master pseudo-device and show it to the user.
The terminal emulator process must also handle terminal control commands, e.g., for resizing the screen. Widely used terminal emulator programs include xterm, GNOME Terminal, Konsole, and Terminal. Remote login handlers such as ssh and telnet servers play the same role but communicate with a remote user instead of a local one. Also consider programs such as expect.
Screen and Tmux are used to add a session context to a pseudoterminal, making for a much more robust and versatile solution. For example, each provides terminal persistence, allowing a user to disconnect from one computer and then connect later from another computer.