What is special About/dev/tty?

Source: Internet
Author: User

ls -la /dev/ttyShows 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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.