Tty command
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
Examples
To display your current terminal connected to standard input, enter:
tty
Sample outputs:
/dev/pts/0
OR
echo "Your current terminal $(tty)"
Where,
- /dev - The device directory.
- pts - It is a pseudo terminal.
- 0 - Your pseudo terminal number.
See also