Chapter 9: Terminal I/O and Changing Terminal Behavior
In this chapter, we learn what a TTY (short for TeleTYpewriter) and a PTY (short for Pseudo-TeletYpewriter) are and how to get information about them. We also learn how to set their attributes. Then, we write a small program that takes input without echoing the text—perfect for a password prompt. We also write a program that checks the size of the current terminal.
A terminal can take many forms—for example, a terminal window in X (the graphical frontend); the seven terminals accessed with Ctrl + Alt + F1 through F7; an old serial terminal; a dial-up terminal; or a remote terminal such as Secure Shell (SSH).
A TTY is a hardware terminal, such as the consoles accessed with Ctrl + Alt + F1 through F7, or a serial console.
A PTY, on the other hand, is a pseudo-terminal, meaning it's emulated in software. Examples of PTYs are programs such as xterm
, rxvt
, Konsole, Gnome Terminal, or a terminal multiplexer...