Tty command

From Linux Bash Shell Scripting Tutorial Wiki
Jump to navigation Jump to search

The tty command will display the file name of the terminal connected to standard input i.e. the name of the current terminal. It displays not a tty message if standard input is not a terminal.

tty command exit status

You can use the following exit status in a shell script:

  • 0 if standard input is a terminal
  • 1 if standard input is not a terminal
  • 2 if given incorrect arguments
  • 3 if a write error occurs


To display your current terminal connected to standard input, enter:


Sample outputs:



echo "Your current terminal $(tty)"


See also