/Dev/tty/dev/ttys0/dev/tty0 difference (reprinted)

Source: Internet
Author: User

1. Serial Port Terminal (/dev/ttysn)

The serial port terminal (serial port terminal) is a terminal device connected by a computer serial port. The computer regards each serial port as a character device. For some time, these serial port devices are usually called terminal devices, because at that time they were used to connect terminals. The device names corresponding to these serial ports are/dev/TTS/0 (or/dev/ttys0),/dev/TTS/1 (or/dev/ttys1), etc, the device numbers are (), (), and so on, respectively, corresponding to COM1 and com2 in the DOS system. To send data to a port, you can Redirect the standard output to these special file names.. For example, type: Echo test>/dev/ttys1The "test" is sent to the device connected to the ttys1 (com2) port.

3. control terminal (/dev/tty)If the current process has a control terminal (controlling terminal),/dev/tty is the device special file of the control terminal of the current process. You can use commands "PS-Ax"To view which control terminal the process is connected. For the shell you log on to,/dev/tty is the terminal you are using, and the device number is (5, 0 ). Run the "tty" command to check which actual terminal device it corresponds. /Dev/tty is similar to a connection to the actually used terminal device.
4. Console terminal (/dev/ttyn,/dev/console)In Linux, a computer monitor is usually called a console ). It simulates a Linux terminal (term = Linux), and some special files of the device are associated with it: tty0, tty1, tty2, and so on. When you log on to the console, tty1 is used. With Alt + [F1-F6] keys, we can switch to tty2, tty3 and so on. Tty1-tty6 is called virtual terminal, and tty0 is an alias of the current virtual terminal, the information generated by the system will be sent to the terminal (also called the console terminal ). Therefore, no matter which virtual terminal is being used, the system information will be sent to the console terminal.
/Dev/console refers to the console, which is a device that interacts with the operating system. The system directly outputs some information to the console. Currently, users can log on to the console only in single-user mode.
TTY:
If a process has a control terminal,/dev/tty is its control terminal. This is not fixed. Different programs may point to different terminals when opening the device file.
# Echo "test">/dev/tty
Test
Tty0:
Tty1-tty6 is called a virtual terminal, while tty0 is an alias of the currently used virtual terminal. The information generated by the system will be sent
This terminal. Therefore, no matter which virtual terminal is being used, the system information will be sent to the console terminal.
# Echo "test">/dev/tty0
Test
(Note: it seems that it is only available in text mode)
/Dev/tty is mainly for processes, while/dev/tty0 is for the entire system.
That is to say, it is the same as the/dev/tty file. For different processes, the specific points are different.
But for that process/dev/tty0 points to the current virtual terminal.

/Dev/tty/dev/ttys0/dev/tty0 difference (reprinted)

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.