/Dev/tty/dev/ttys0/dev/tty0,/dev/null

Source: Internet
Author: User

1./dev/tty indicates the control terminal
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 run the "PS-Ax" command to check 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.

[Email protected]:/dev # echo "test">/dev/tty
Test (output test)

 


The control terminal can be a Pseudo Terminal (/dev/pts/*) in xwindows mode or a console virtual terminal (/dev/tty *)

  1. If (device = mkdev (5, 0 )){
  2. Tty = get_current_tty ();
  3. If (! TTY ){
  4. Mutex_unlock (& tty_mutex );
  5. Return-enxio;
  6. }
  7. Driver = tty_driver_kref_get (tty-> driver );
  8. Index = tty-> index;
  9. Filp-> f_flags | = o_nonblock;/* Don't let/dev/tty block */
  10. /* Noctty = 1 ;*/
  11. /* Fixme: shocould we take a driver reference? */
  12. Tty_kref_put (TTY );
  13. Goto got_driver;
  14. }

"Driver" corresponds to the driver, and "Index" corresponds to a specific device. We can also see that/dev/tty is similar to a link to the actually used terminal device.
2./dev/tty0 is an alias for the current virtual terminal.

  1. # Tty (view the current TTY)
  2. /Dev/tty1
  3. # Echo "test tty0">/dev/tty0
  4. Test tty0

The kernel implementation is as follows:

    1. If (device = mkdev (4, 0 )){
    2. Extern struct tty_driver * console_driver;
    3. Driver = tty_driver_kref_get (console_driver );
    4. Index = fg_console;
    5. Noctty = 1;
    6. Goto got_driver;
    7. }


Shell may often see:>/dev/null 2> & 1

Command results can be defined in the form of %>

/Dev/null indicates an empty device file.

The statement in the title of this article:
1>/dev/null indicates that the standard output is redirected to an empty device file, that is, no information is output to the terminal. In other words, no information is displayed.
2> & 1 next, the standard error output redirection is equivalent to the standard output. Because the standard output has been redirected to the empty device file, the standard error output is also redirected to the empty device file.

 

Reference: http://blog.csdn.net/suiyuan19840208/article/details/7234722

 

Http://blog.chinaunix.net/uid-26696487-id-3207777.html

 

/Dev/tty/dev/ttys0/dev/tty0,/dev/null

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.