Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Terminal / TTY

Direct answer

A terminal (TTY) is the device a shell reads from and writes to: physical consoles (/dev/tty1), serial lines (/dev/ttyS0) and pseudo-terminals for SSH and terminal windows (/dev/pts/N). It handles line editing, signals such as Ctrl+C and window size.

When to use this

Use it when a session hangs, output is garbled, Ctrl+C does nothing, or a program needs a TTY.

First 30 seconds

1. tty — on a pts (SSH/terminal) or a console?

2. Garbled output or no echo → reset (type it blind).

3. Program says "not a tty" → run with ssh -t or from a real terminal.

4. Ctrl+C ignored → the program traps SIGINT; try Ctrl+\ or kill from another session.

5. who — other sessions holding the terminal?

Operational verification

terminal device opened → shell attached → line discipline handles input and signals → program reads and writes

Evidence · next step

For Linux Fundamentals → Terminal / TTY, continue with the first unproven Topic check: Identify local console versus PTY/remote session and whether a controlling terminal exists. If that boundary is healthy, advance to the adjacent check: Correlate terminal device/session with the shell or application process actually using it. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it when a session hangs, output is garbled, Ctrl+C does nothing, or a program needs a TTY.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

session/transport → TTY or PTY allocation → controlling-terminal relationship → terminal modes/line discipline → shell/application I/O + signals → interactive behavior

Healthy evidence: the session type, terminal device/allocation, controlling-process relationship and terminal modes explain the observed interactive behavior.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Identify local console versus PTY/remote session and whether a controlling terminal exists.

  • Correlate terminal device/session with the shell or application process actually using it.
  • Check terminal mode, dimensions and interactive assumptions when input/output or job control behaves differently.
  • Reproduce with and without TTY allocation when isolating terminal-specific behavior from shell/application behavior.

Verification chain. session/transport → TTY or PTY allocation → controlling-terminal relationship → terminal modes/line discipline → shell/application I/O + signals → interactive behavior

Step 3 Commands Verify boundary
tty
who
stty -a
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: SSH success is assumed to imply TTY allocation, shell problems are diagnosed from terminal symptoms alone, or stdin/stdout pipes are mistaken for a controlling terminal.

Step 5 Common mistakes Narrow the fault
  • Running interactive commands in non-TTY automation.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

reset fixes a terminal left in a bad mode. Programs run without a TTY (cron, ssh host cmd) cannot prompt for passwords — use ssh -t to force one. Ctrl+C sends SIGINT, Ctrl+Z SIGTSTP, Ctrl+D end-of-input.

Key checks
  • tty — the terminal device of this shell
  • who — logged-in users and their TTYs
  • stty -a — terminal settings
  • reset — restore a broken terminal
ReferenceWhat it is1 section · depth on demand

Core model

Identify whether the session uses a console, TTY or PTY and which process owns the controlling terminal. Separate transport/session creation from terminal settings and from shell/application behavior. Trace input/output, signal/job-control and line-discipline expectations before blaming the command interpreter.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

TTY allocation shows an interactive endpoint exists, not that transport, shell parsing, authentication or the application itself is healthy.

In depth

Terminals, TTYs and pseudo-terminals

A terminal is the device a shell reads input from and writes output to. Historically it was physical hardware. Today it's almost always a pseudo-terminal (pty), a pair of virtual devices created by the kernel. The pts(4) manual page explains how it works:

  • Opening /dev/ptmx gives a process the master side, and creates a matching slave device /dev/pts/N.
  • The slave behaves like a classic terminal: the shell reads from it and writes to it.
  • The program holding the master, such as a terminal emulator or sshd, passes data in both directions.
  • The /dev/pts directory is a mounted devpts file system.

Kinds of terminals

DeviceWhat it isExample
/dev/tty1–/dev/tty6Virtual consoles on the local screenCtrl+Alt+F2
/dev/ttyS0Serial portSerial console for servers and VMs
/dev/pts/NPseudo-terminal slaveSSH sessions, terminal emulators, tmux panes
/dev/ttyThe current process's controlling terminalPrompting for a password even when stdout is redirected
/dev/consoleThe system consoleKernel messages during boot

What the terminal layer does

FeatureExample
Line editing before input reaches the programBackspace in "cooked" mode
Signal charactersCtrl+C sends SIGINT; Ctrl+Z SIGTSTP; Ctrl+\ SIGQUIT
End of inputCtrl+D
Window sizeThe emulator tells the kernel; programs get SIGWINCH
Session endingClosing the terminal sends SIGHUP to the session

Useful commands

TaskCommand
Which terminal am I on?tty
Who is logged in on which terminalwho, w
Terminal settingsstty -a
Repair a scrambled terminalreset or stty sane
Is the input a terminal? (in scripts)[ -t 0 ]
Force a pty for a remote commandssh -t host top
host$ tty
/dev/pts/2
host$ who
admin    pts/2        2026-11-28 15:30 (10.110.0.5)
deploy   pts/3        2026-11-28 16:01 (10.110.0.8)
host$ ps -o pid,tty,comm -t pts/3
    PID TT       COMMAND
   7712 pts/3    bash
   7790 pts/3    vim
host$ stty -a | grep -oE "intr = [^;]+|rows [0-9]+; columns [0-9]+"
host$ ssh srv2 'tty; [ -t 0 ] && echo terminal || echo "no terminal"'
not a tty
no terminal
host$ ssh -t srv2 'tty'
/dev/pts/0

Reading the SSH example

A command run through ssh host command gets no pseudo-terminal, so tty reports "not a tty". Interactive programs such as top, sudo with a password prompt, or editors need ssh -t. Scripts can use [ -t 0 ] to tell an interactive run from an automated one.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Terminal / TTY is part of Linux Fundamentals → Terminal / TTY. Terminal / TTY describes the character-oriented session endpoint used by interactive programs: physical/virtual consoles, terminal emulators and pseudo-terminals provide I/O and terminal semantics, while a shell is merely one process that may attach to a controlling terminal.

Topic-specific state model. Terminal / TTY describes the character-oriented session endpoint used by interactive programs: physical/virtual consoles, terminal emulators and pseudo-terminals provide I/O and terminal semantics, while a shell is merely one process that may attach to a controlling terminal.

Interpretation rule. - Terminal emulator ≠ shell.

  • SSH connection ≠ guaranteed interactive TTY allocation.
  • Process has stdin/stdout ≠ process has a controlling terminal.
  • TTY present ≠ terminal dimensions, modes, encoding or job-control state are correct.

Quick reference

A terminal (emulator) displays a TTY device; the shell reads/writes it. Device types: virtual consoles (/dev/tty1), pseudo-terminals for SSH and terminal emulators (/dev/pts/N), serial consoles (/dev/ttyS0).

tty
who; w
stty -a                         # terminal settings
reset                           # fix a garbled terminal
script -q -c 'cmd' session.log  # record a session

Use tmux or screen on servers so long tasks survive SSH disconnects (tmux new -s upgrade, reattach with tmux attach -t upgrade). Ctrl+S freezes terminal output; Ctrl+Q resumes.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. TTY allocation shows an interactive endpoint exists, not that transport, shell parsing, authentication or the application itself is healthy.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. Terminal / TTY owns terminal/session semantics; SSH transport/authentication stays under SSH and shell language behavior under Shell/Shell & Bash.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Linux Fundamentals → Terminal / TTY. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.kernel.org/ · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
tty linuxpty linuxterminal vs shell linux
Embedded reference data

Quick lookup tables

Terminal / TTY operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Terminal / TTY.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateTerminal / TTY describes the character-oriented session endpoint used by interactive programs: physical/virtual consoles, terminal emulators and pseudo-terminals provide I/O and terminal semantics, while a shell is merely one process that may attach to a controlling terminal.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin distribution/release + CPU architecture + running kernel → identify the exact process/session and kernel-versus-user-space boundary → capture shell/TTY mode and effective environment where relevant → resolve the real executable/consumer → correlate requested action with observed runtime state → verify the original workload result before changing persistent configuration.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainsession/transport → TTY or PTY allocation → controlling-terminal relationship → terminal modes/line discipline → shell/application I/O + signals → interactive behaviorTrace requested/configured state through effective state to the observed workload result.
Failure boundaryTTY allocation proves an interactive endpoint exists, not that transport, shell parsing, authentication or the application itself is healthy.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated host, process/session and runtime evidence can establish this Linux Fundamentals proof path: session/transport → TTY or PTY allocation → controlling-terminal relationship → terminal modes/line discipline → shell/application I/O + signals → interactive behaviorUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured host, kernel, process/session, environment or workload scope. TTY allocation proves an interactive endpoint exists, not that transport, shell parsing, authentication or the application itself is healthy.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven Linux layer: preserve platform identity and the running kernel, inspect the exact process/session and effective configuration/environment, resolve the actual consumer/executable, then verify the original workload before moving into the owning Linux subsystem branch.Continue to the next unresolved boundary while preserving the original test condition.

Terminal / TTY · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryTerminal / TTY
Topic pathLinux Fundamentals → Terminal / TTY
Runtime stateTerminal / TTY describes the character-oriented session endpoint used by interactive programs: physical/virtual consoles, terminal emulators and pseudo-terminals provide I/O and terminal semantics, while a shell is merely one process that may attach to a controlling terminal.
Fast checks- Identify local console versus PTY/remote session and whether a controlling terminal exists. - Correlate terminal device/session with the shell or application process actually using it. - Check terminal mode, dimensions and interactive assumptions when input/output or job control behaves differently. - Reproduce with and without TTY allocation when isolating terminal-specific behavior from shell/application behavior.
Verification chainsession/transport → TTY or PTY allocation → controlling-terminal relationship → terminal modes/line discipline → shell/application I/O + signals → interactive behavior Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundaryTTY allocation proves an interactive endpoint exists, not that transport, shell parsing, authentication or the application itself is healthy. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?