tty — Return the user's terminal name

Format

tty [–s]

Description

tty displays the file name of the terminal device associated with the standard input.

Options

–s
Does not display the name; the exit status of tty indicates whether the standard input is a terminal.

Localization

tty uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

See Localization for more information.

Exit values

0
Standard input is a terminal
1
Standard input is not a terminal
2
Failure because of an unknown command-line option, or too many arguments

Messages

Possible error messages include:
Not a tty
The standard input is not associated with a terminal.

Portability

POSIX.2, X/Open Portability Guide, UNIX systems.

The POSIX standard considers the -s option to be obsolete.