Chapter 2: Terminal
Early Terminals
Early terminals were standalone hardware devices used to connect to main computers or servers. They typically included:
- Input Device: such as a keyboard, used for inputting commands and data.
- Output Device: such as a display or printer, used for displaying calculation results and system feedback.
Examples: early Teletype (tty) terminals, DEC VT100 terminals.
Modern Terminals
Modern terminals exist more in software form, i.e., terminal emulators, running as applications in modern operating systems (such as Linux, macOS, Windows), simulating the functions of early hardware terminals.
Terminal Emulators
Terminal | Description |
---|---|
iTerm2 | Advanced terminal emulator on macOS systems, offering rich features like split screens, tabs, and search. |
GNOME Terminal | Default terminal emulator commonly found on Linux systems, powerful and easy to use. |
PuTTY | Widely used SSH client on Windows systems, suitable for remote connections and management. |
Windows Terminal | Modern terminal emulator on Windows systems, supporting multiple command-line environments like PowerShell, CMD, WSL. |
Teletype
Although Teletype devices are no longer in use, their concept and functionality are still preserved in Linux.
/dev/tty
You can see its file type is c
(character device), representing the terminal device connected to the current process.
Its permission is 666
, major device number is 5
, minor device number is 0
, which is what we commonly see as standard input/output.
/dev/pts
PTS stands for Pseudo-Terminal, /dev/pts
is a directory for storing pseudo-terminal device files.
Listing the files in the /dev/pts
directory, you will generally see two types of files.
- ptmx: Master Device, used for creating and managing pseudo-terminal pairs.
- 0/1/2: Slave Device, each corresponding to a number for an
ssh
session.
Entering the tty
command in the command line can show the pseudo-terminal device file currently connected.
Get Logged-in User
The most common method is the w
command.
You can also use the who
command.
Of course, you can directly use ls
as well.