Use it when a session hangs, output is garbled, Ctrl+C does nothing, or a program needs a TTY.
Terminal / TTY
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.
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?
terminal device opened → shell attached → line discipline handles input and signals → program reads and writes
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
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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 · 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.
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.
tty— the terminal device of this shellwho— logged-in users and their TTYsstty -a— terminal settingsreset— 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/ptmxgives 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/ptsdirectory is a mounted devpts file system.
Kinds of terminals
| Device | What it is | Example |
|---|---|---|
/dev/tty1–/dev/tty6 | Virtual consoles on the local screen | Ctrl+Alt+F2 |
/dev/ttyS0 | Serial port | Serial console for servers and VMs |
/dev/pts/N | Pseudo-terminal slave | SSH sessions, terminal emulators, tmux panes |
/dev/tty | The current process's controlling terminal | Prompting for a password even when stdout is redirected |
/dev/console | The system console | Kernel messages during boot |
What the terminal layer does
| Feature | Example |
|---|---|
| Line editing before input reaches the program | Backspace in "cooked" mode |
| Signal characters | Ctrl+C sends SIGINT; Ctrl+Z SIGTSTP; Ctrl+\ SIGQUIT |
| End of input | Ctrl+D |
| Window size | The emulator tells the kernel; programs get SIGWINCH |
| Session ending | Closing the terminal sends SIGHUP to the session |
Useful commands
| Task | Command |
|---|---|
| Which terminal am I on? | tty |
| Who is logged in on which terminal | who, w |
| Terminal settings | stty -a |
| Repair a scrambled terminal | reset or stty sane |
| Is the input a terminal? (in scripts) | [ -t 0 ] |
| Force a pty for a remote command | ssh -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.
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.
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
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
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%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.
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.
Quick lookup tables
Terminal / TTY operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Terminal / TTY.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | 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. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin 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 chain | session/transport → TTY or PTY allocation → controlling-terminal relationship → terminal modes/line discipline → shell/application I/O + signals → interactive behavior | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | TTY 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 evidence | Correlated 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 behavior | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It 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 check | Continue 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 boundary | Terminal / TTY |
|---|---|
| Topic path | Linux Fundamentals → Terminal / TTY |
| Runtime state | 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. |
| 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 chain | session/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 boundary | TTY 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 rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |