tty - macOS


The tty command identifies the file associated with the standard input of the current shell and displays its device name. It is useful for determining the terminal associated with the current shell or identifying the input source of a piped command.


tty [options]


  • -s or –silent: Suppresses printing the device name if the standard input is a terminal.
  • -c or –canonical: Considers the standard input as a canonical terminal device, even if it is not. This option is typically used in conjunction with -s to suppress output when the input is not a terminal.


  • Display the device name associated with standard input:
  • Suppress output if the standard input is a terminal:
tty -s
  • Consider the standard input as a terminal:
tty -c

Common Issues

  • “No such device or address” error: This error occurs when the standard input is not a file or a terminal device. Ensure that the input is coming from a valid source.
  • Incorrect device name: The displayed device name may not always be intuitive. Refer to the macOS documentation or use the ls -l /dev command to map the device name to its corresponding terminal.


tty can be combined with other commands to determine the input source or handle terminal-related tasks. For example:

  • Pipe tty output to xargs to list files opened by the terminal:
tty | xargs lsof -c
  • ps: Displays process information, including the terminal associated with each process.
  • stty: Sets or gets terminal settings.