ls -la /dev/tty shows the output:
crw-rw-rw- 1 root tty 5, 0 Dec 14 22:21 /dev/tty
What does c at the beginning mean? When I do something like pwd > /dev/tty it prints to the stdout. What does the file /dev/tty contain?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 is interfaced byte-by-byte (as opposed to buffered IO).
TTY
/dev/tty is a special file, representing the terminal for the current process. So, when you
echo 1 > /dev/tty, your message (‘1’) will appear on your screen. Likewise, when youcat /dev/tty, your subsequent input gets duplicated (until you press Ctrl-C)./dev/ttydoesn’t ‘contain’ anything as such, but you 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 are similar files which are very useful for simple IO operations (e.g./dev/ttyS0is normally your serial port)This quote is from http://tldp.org/HOWTO/Text-Terminal-HOWTO-7.html#ss7.3 :
Here is the man page: http://linux.die.net/man/4/tty