maux
Star on GitHub Buy me a coffee

Manual / tty

tty(1)

TTY(1) General Commands Manual TTY(1)

tty - print the terminal attached to standard input

tty

Tty writes the name of the terminal attached to standard input, one of /dev/tty1 through /dev/tty4 (the four consoles) or /dev/ttya0 (the Super Serial Card line). If standard input is not a terminal, tty writes not a tty instead. There are no operands; one given is a usage error, exit status 2.

/usr/man/TTY this page

stty(1), chvt(1)

Exit status is 0 if standard input is a terminal, 1 if it is not, 2 if standard input's file descriptor could not be inspected at all (closed, or out of range).

/dev/null is a device by this system's own buffering rules but is not a terminal by any Unix's definition, so tty reports it as not a tty, narrower than the isatty test some other maux code uses for buffering decisions alone. The historical -s option (silence the name, keep only the exit status) is not implemented -- POSIX.1-2024 itself removed it as obsolescent.

September 14, 2026 maux