Strovent SystemsSign in
Reference

VT and xterm basics

Escape sequences, keys, colors and terminal types for Unix and Linux hosts.

VT, xterm and terminal typesWhat a VT100, VT220 and xterm terminal are, and how they differ from 3270 and 5250.Escape sequencesWhat an escape sequence is and the handful you will see most often.Escape sequence tableA reference table of common VT100, VT220 and xterm sequences: cursor, erase, style, modes and OSC.Keys and key codesWhat the arrow, function, Home, End and Ctrl keys send, and why Backspace and Delete confuse people.Colors: 16, 256 and true colorHow terminal colors work, what 256-color and true color mean, and how to turn them on.Alternate screen, mouse and paste modesThe terminal modes full-screen programs switch on: alternate screen, mouse reporting and bracketed paste.TERM and terminfoHow a host learns what your terminal can do, and what to do when it says the terminal type is unknown.Telnet basicsWhat Telnet is, how options are negotiated, and why it should not carry passwords on its own.Boxes show as q, x and lqqqk in a terminalWhy borders appear as letters like lqqqk and x in SSH and Mosh sessions, how the VT100 line-drawing character set works, and how TERM and the locale affect it.Clear the terminal screen and its scrollbackWhat clear and reset do to the screen and the scrollback, why old lines can still be there after clear, and the escape sequence that erases saved lines.Telnet echo, typed characters twice, missing or visible passwordsHow the Telnet ECHO and SUPPRESS-GO-AHEAD options decide who shows your typing, and why characters appear twice, not at all, or in the clear.Fix a terminal full of garbage after printing a binary fileWhy letters turn into line-drawing symbols or typing stops echoing after you cat a binary file, and how reset, stty sane and Ctrl+O bring the terminal back.Telnet "Connection closed by foreign host"Connection closed by foreign host means the far end closed the Telnet connection. When it appears shows why: access rules, a port test, login timeout or logout.Check if a TCP port is open without Telnet: nc, Test-NetConnection, bashTest whether a host answers on a TCP port without a Telnet client: nc -vz on macOS and Linux, Test-NetConnection in PowerShell, or bash /dev/tcp.Telnet IAC codes: reading FF FB 01, WILL, WONT, DO and DONT in a traceWhat the bytes 255 251 1 (FF FB 01) mean in a Telnet trace: the IAC command codes, common option numbers, subnegotiation, and how to read a negotiation log.Shift+Enter or Ctrl+Enter acts like Enter in a terminal: why, and how to fix itA terminal sends the same carriage return for Enter, Shift+Enter and Ctrl+Enter unless the program turns on an extended key mode. Ctrl+J often works instead.Ctrl+Space not working over SSH or in tmux: the NUL byte and how to test itCtrl+Space sends one NUL byte (0x00), the same as Ctrl+@. Test with od -c on the host to see if it arrives; old Windows ssh.exe and OS shortcuts can drop it.Turn on the Telnet client in Windows: "telnet is not recognized"Windows ships without the Telnet client installed. Turn it on with DISM or PowerShell, then use telnet host port, the escape prompt and quit.VT220 keypad on OpenVMS: PF1 (GOLD) to PF4 and application keypad from a PC or tabletWhere PF1 to PF4 and the VT keypad keys are on a PC or tablet keyboard, what GOLD means in EDT, and why keypad keys type digits instead of commands.TERM xterm, xterm-color or xterm-256color: which to useWhat the TERM values xterm, xterm-color and xterm-256color mean in terminfo, why xterm-color is an old choice, and which one to set for SSH, tmux and vim.Do all terminals understand ANSI escape codes? TERM, terminfo and dumb terminalsNot every terminal supports every escape code, and output can go to a file or a dumb terminal. Why, and how tput and terminfo pick the right codes.Mouse hover doesn't work in a TUI over SSH, tmux or Mosh: mouse modes 1000, 1002 and 1003Hover needs any-event mouse reporting (mode 1003), which reports movement with no button held. Find which layer drops it: your terminal, tmux or Mosh.Ctrl+C copies instead of interrupting, or Ctrl+V and Ctrl+A never reach the hostSome terminal programs keep Ctrl+C, Ctrl+V or Ctrl+A for copy, paste and select. Then the key never reaches the host. How to tell, and the keys to use instead.Terminal frozen after Ctrl+S: XON/XOFF flow control and Ctrl+QCtrl+S tells the host's terminal driver to stop output, so the screen looks frozen. Press Ctrl+Q to resume, or turn it off with stty -ixon.Pasted text shows ^[[200~ and ^[[201~: bracketed paste mode left on200~ and 201~ around pasted text are bracketed paste markers. A program turned the mode on and the one reading now does not expect it. How to switch it off.less shows ESC[31m instead of colors: less -R and --color=alwaysColored output piped into less shows ESC[31m and ESC[0m because less prints control characters as text. Use less -R, and make the program keep its colors.tput "No value for $TERM and no -T specified" and "TERM environment variable not set"tput and clear need TERM to know your terminal. Cron jobs, services and ssh host command run without one. Guard the call, pass -T, or set TERM yourself.

Other categories