ls -la /dev/tty
Shows the output:
crw-rw-rw- 1 root tty 5, 0 Dec 14 22:21 /dev/tty
The ' C ' means it ' s a character device. TTY is a special file representing the ' controlling terminal ' for the current process.
Character Devices
Unix supports ' device files ', which aren ' t really files at all, but file-like access points to hardware devices. A ' character ' device is one which are interfaced byte-by-byte (as opposed to buffered IO).
Tty
/dev/tty is a special file, representing the terminal for the current process. So if you echo 1 > /dev/tty
, your message (' 1 ') would appear on your screen. Likewise, when you cat /dev/tty
, your subsequent input gets duplicated (until you press ctrl-c).
/dev/tty doesn ' t ' contain ' anything as such, but can read from it and write to it (for what it ' s worth). I can ' t think of a good use for it, but there is similar files which is very useful for simple IO operations (e.g./dev/ TtyS0 is normally your serial port)
Original From:http://stackoverflow.com/questions/8514735/what-is-special-about-dev-tty
What is special About/dev/tty?