Unix-like systems include a Terminfo database that describes the capabilities of various terminals. When a program needs to perform terminal operations, it reads the TERM environment variable to identify your terminal type, then queries the Terminfo database to determine available capabilities and how to use them. This affects output formatting, colour handling, cursor movements, and other terminal behaviour.