unix Is a multi-user and multi task operating system. Early computers were expensive, So we used cheap devices to connect to computers( There was no keyboard or monitor, Use paper tape and cards for input and output) To use the operating system, This cheap device is the terminal, It can also be regarded as a console. So we can think of the computer itself asconsole terminal, Cheap connectivity devices are physical terminalspty.

Linux Yes.unix system, So it also inherits the characteristics of the terminal. But then computers became cheaper, There are also monitors and keyboards, So you can use the keyboard as the input terminal, Display as output terminal, These terminals are virtual terminals, Virtual terminal is virtual console, Or a virtual device.

Linux Many kinds of virtual terminals are provided, UsettyN Express, UseCtrl+Alt+F[1-6] Can switch virtual terminals, These terminal devices are recorded in/dev/ Directory.
[[email protected] ~]# ls /dev/tty tty tty12 tty17 tty21 tty26 tty30 tty35 tty4 tty44
tty49 tty53 tty58 tty62 ttyS0 tty0 tty13 tty18 tty22 tty27 tty31 tty36 tty40
tty45 tty5 tty54 tty59 tty63 ttyS1 tty1 tty14 tty19 tty23 tty28 tty32 tty37
tty41 tty46 tty50 tty55 tty6 tty7 ttyS2 tty10 tty15 tty2 tty24 tty29 tty33
tty38 tty42 tty47 tty51 tty56 tty60 tty8 ttyS3 tty11 tty16 tty20 tty25 tty3
tty34 tty39 tty43 tty48 tty52 tty57 tty61 tty9

tty Plus the value is the virtual terminal,CTRL+ALT+F1 Indicates switch totty1 terminal,ctrl+alt+f2 Indicates switch totty2 terminal, commonlyLinux Only available onctrl+alt+f[1-6] this6 Function of switching between terminals. Two special terminals aretty andtty0,tty Indicates the terminal currently in use,tty0 Indicates all virtual terminals currently activated. AlsottySN, These represent serial terminals.

Also fromssh ortelnet Waiting to connect to the terminal on the computer from the network, Or command line terminal opened from graphic virtual terminal, They are called pseudo terminals, Usepts/N Express, The corresponding equipment is/dev/pts Values in the table of contentsN file.
[[email protected] ~]# ls /dev/pts/ 0 ptmx
0 Indicates the first pseudo terminal,1 Indicates the second pseudo terminal.

The management mode of pseudo terminal is different from that of all other terminals, It is managed by a program that connects to a computer, for examplessh Connection byssh Apply for pseudo terminal resources, And require user name and password. Ifssh Connection process killed, Then the pseudo terminal exits accordingly.

in addition, Some authentication programs do not always assign terminals to connection slaves, For example, executionsudo ssh Time,sudo Not necessarilyssh Assign pseudo terminal.

In modern timesLinux upper,console The terminal has a different meaning from the original, Its devices are mapped in/dev/console upper, All kernel output information is output toconsole terminal, The information output by other user programs is output to virtual terminal or pseudo terminal.

Sum up:

/dev/console: Console terminal

/dev/ttyN: Virtual terminal,ctrl+alt+f[1-6] The virtual terminal is switched

/dev/ttySN: Serial terminal

/dev/pts/N: Pseudo terminal,ssh The command line terminal opened by the tool connecting the past live graphic terminal is the pseudo terminal.