linux – tty,ttyS,pts,ptmx,vcs,vcsa设备文件之间的区别?

终端有字符终端和图形终端两种模式。在linux的图形环境下,我们可以通过鼠标点击来完成所有的管理任务,这是图形界面终端,另外一种就是文本界面的终端,

在这个界面的终端下我们可以使用linux命令来控制系统完成响应的工作,而这个文本终端也是服务器常用的模式

图形终端

字符终端

终端是一种字符型设备,它有多种类型,通常使用tty来简称各种类型的终端设备

物理终端:系统启动之前的控制台叫物理终端

虚拟终端:由软件虚拟出来的,系统启动之后由程序启动的终端,例如由mingetty程序启动的6个tty叫虚拟终端

模拟终端:远程登录或图形界面(startx)或pts

物理终端 /dev/console       串口调试Linux内核
虚拟终端 /dev/tty(0,6)    -》login程序   用户名/密码
模拟终端 /dev/pts/#       -》sshd程序  用户名/密码

console和terminal有什么区别?

简单来看,console就是计算机的原生的设备

  1. [root@ht8 pts]# ll /dev | grep con
  2. crw------- 1 root root 5, 1 Jan 5 19:39 console
  3.  
  4. [root@ht8 pts]# cat /proc/devices | grep console
  5. Character devices:
  6. 5 /dev/console
    所谓的terminal是附加的设备,通过串口或事其他设备连接。也就是说console(原生设备)只有一个,但是terminal(附加设备)可以有多个

linux中的TTY是什么? TTY,是teletypewriter的缩写,翻译过来就是电传打字机

  1. 说到LinuxTTYUNIXLinux中的抽象设备。有时它指的是物理输入设备,如串行端口,有时它指的是允许用户与系统交互的虚拟TTY
  2. TTYLinuxUnix中的一个子系统,通过TTY驱动程序在内核级别实现流程管理、编辑和会话管理。
  3. 实际上,每当启动终端模拟器或使用系统中的任何类型的shell时,它都会与被称为伪TTYPTY的虚拟TTY进行交互。
  4.  
  5. 您只需在终端模拟器中键入TTY即可找到关联的PTY.

在Linux系统的设备特殊文件目录/dev/下,终端设备文件有以下几种:

1)/dev/tty(控制终端)

   tty是所有终端的统称,包括串口、控制台终端以及伪终端设备。

 通过tty命令可以知道当前具体是什么终端(所以tty也代表当前的终端,echo hello > /dev/tty都会显示在当前的终端中,可能是上面的任意一种终端)。

dev/tty就是映射到dev/tty1-6之间的一个(取决于你当前的控制台号), 如果你现在是在图形界面(Xwindows),通过键盘快捷键 Ctrl+Alt+F1~6进行切换到不同的终端上

比如你可以输入命令 #tty 那么将显示当前映射终端如:/dev/tty1或者/dev/pts/0等。

  1. 目前我登录了2个终端
    [root@ht8 src]# w
  2. 16:07:59 up 80 days, 19:29, 2 users, load average: 0.59, 0.73, 0.72
  3. USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
  4. root pts/0 10.129.55.19 Sat10 7.00s 0.54s 0.00s w
  5. root pts/1 10.129.55.19 Sat20 16:18m 0.03s 0.03s -bash
    //查看谁登录了该系统,同时可以杀死其他终端,从而把对方踢出去.

[root@ht8 src]# tty
  /dev/pts/0

##/dev/tty是当前进程的控制终端的设备文件,可以使用命令”ps -ax”来查看进程与哪个控制终端相连。

[root@ht8 src]# ps -ef | grep tty
 root 843 1 0 Jan05 tty1 00:00:00 /sbin/agetty --noclear tty1 linux
 root 43237 37454 0 16:08 pts/0 00:00:00 grep --color=auto tty

##sbin/agetty就是用于打开一个tty终端,显示登录页面,agetty管理着虚拟控制台

//发送一个字符到另一个登录的终端(加入多个人登录了终端,就可以发给对方消息)

[root@ht8 ~]# echo "test,hello">/dev/pts/0

//从另外一个终端就是可以看到
[root@ht8 src]# test,hello

[root@ht8 src]# dmesg |grep tty
[ 0.000000] console [tty0] enabled  //  看到这个启用.

pts--->对应多个tty

[root@ht8 pts]# pwd
/dev/pts
[root@ht8 pts]# ll
total 0
crw--w---- 1 root tty 136, 0 Mar 27 2022 0
crw--w---- 1 root tty 136, 1 Mar 27 16:38 1
crw--w---- 1 root tty 136, 2 Mar 27 17:24 2
c--------- 1 root root 5, 2 Jan 5 19:39 ptmx

在不同终端输出的数字就是tty终端号

[root@ht8 ~]# tty
/dev/pts/1

添加一个设备到/dev下则可以

  1. [root@ht8 dev]# mknod /dev/tty100 c 4 100 
    //语法 建立一个名为tty100的设备文件,c表示是字符文件,major(主设备号)=4, minor(次设备号)=100
  2. [root@ht8 dev]# ll /dev/ | grep tty100
  3. crw-r--r-- 1 root root 4, 100 Mar 27 20:49 tty100
  4. //再次执行则会出现......
  5. [root@ht8 dev]# mknod /dev/tty100 c 4 100
  6. mknod: ‘/dev/tty100’: File exists

打开 /etc/systemd/logind.conf 文件并将 NAutoVTs=3 设置为你想要在启动时得到的虚拟控制台数量

  1. [root@ht8 src]# cat /etc/systemd/logind.conf
  2. # This file is part of systemd.
  3. #
  4. # systemd is free software; you can redistribute it and/or modify it
  5. # under the terms of the GNU Lesser General Public License as published by
  6. # the Free Software Foundation; either version 2.1 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # Entries in this file show the compile time defaults.
  10. # You can change settings by editing this file.
  11. # Defaults can be restored by simply deleting this file.
  12. #
  13. # See logind.conf(5) for details.
  14.  
  15. [Login]
  16. NAutoVTs=3
  17. #ReserveVT=6
  18. #KillUserProcesses=no
  19. #KillOnlyUsers=
  20. #KillExcludeUsers=root
  21. #InhibitDelayMaxSec=5
  22. #HandlePowerKey=poweroff
  23. #HandleSuspendKey=suspend
  24. #HandleHibernateKey=hibernate
  25. #HandleLidSwitch=suspend
  26. #HandleLidSwitchDocked=ignore
  27. #PowerKeyIgnoreInhibited=no
  28. #SuspendKeyIgnoreInhibited=no
  29. #HibernateKeyIgnoreInhibited=no
  30. #LidSwitchIgnoreInhibited=yes
  31. #IdleAction=ignore
  32. #IdleActionSec=30min
  33. #RuntimeDirectorySize=10%
  34. #RemoveIPC=no
  35. #UserTasksMax=

关于dev/tty其实很简单:就是当前终端设备的一个链接(有点像/dev/tty0吧,但是他好像更强大一点),我们可以做下这个实验:

在Xwindow下打开多个终端(输入命令的窗口):#tty命令,发现在各个窗口分别显示为# dev/pts/0  #dev/pts/1  #dev/pts/2....

2)/dev/ttySn(串行端口终端)
  计算机把每个串行端口都看作是一个字符设备,若要向一个端口发送数据,可以在命令行上把标准输出重定向到这些特殊文件名上即可。
  例如,在命令行提示符下键入:echo test > /dev/ttyS1会把单词”test”发送到连接在ttyS1(COM2)端口的设备上。这些都是串口,不是并口.

 注意:当今的计算机都配有键盘和显示设备,不再带有多个文本终端。于是“系统控制台”就由本地键盘和监视器担任。而当计算机主机没有连接显示硬件设备时,
   一般就由串口设备 担任“系统控制台”。把串口设备的电缆插入就可以得到诊断信息和登陆提示字

串行端口终端(Serial Port Terminal)是使用计算机串行端口连接的终端设备。linux把每个串行端口都看作是一个字符设备。有段时间这些串行端口设备通常被称为终端设备,因为那时它的最大用途就是用来连接终端。这些串行端口所对应的设备名称是/dev/tts/0(或/dev/ttyS0), /dev/tts/1(或/dev/ttyS1)等,设备号分别是(4,0), (4,1)等,分别对应于DOS系统下的COM1、COM2等。若要向一个端口发送数据,可以在命令行上把标准输出重定向到这些特殊文件名上即可。例如,在命令行提示符下键入:echo test > /dev/ttyS1会把单词”test”发送到连接在ttyS1(COM2)端口的设备上。可接串口来实验。

  1. [root@ht8 pts]# ls -l /dev/ttyS*
  2. crw-rw---- 1 root dialout 4, 64 Jan 5 19:39 /dev/ttyS0
  3. crw-rw---- 1 root dialout 4, 65 Jan 5 19:39 /dev/ttyS1
  4. crw-rw---- 1 root dialout 4, 66 Jan 5 19:39 /dev/ttyS2
  5. crw-rw---- 1 root dialout 4, 67 Jan 5 19:39 /dev/ttyS3

3)/dev/ttyn,/dev/console(控制台终端)
    使用Alt+[F1~6]组合键时,我们可以在tty1、tty2...切换,tty1~tty6等称为虚拟控制台,而tty0则是当前所使用的虚拟控制台的一个别名,系统产生的信息会发送到该终端上。

4)dev/pts/n(虚拟终端)或者叫伪终端
    在XWindows模式下的伪终端,另外远程登陆的用户,就是使用telnet、ssh等远程登陆的用户,他的终端显示就是pts/n。

/dev/pts是远程登录(telnet,ssh等)后创建的控制台设备文件所在的目录

pts是远程虚拟终端。devpts是一个虚拟的文件系统,一般安装在/dev/pts。为了得到一个虚拟终端,进程打开/dev/ptmx,然后就可使用虚拟终端pts。
 /dev/ptmx是master,其他的pts是slave,也就是一对多的关系.

pts与ptmx配合实现/dev/pty虚拟终端

  1. 目前登录2个终端
  2. [root@ht8 pts]# ll
  3. total 0
  4. crw--w---- 1 root tty 136, 0 Mar 27 17:23 0
  5. crw--w---- 1 root tty 136, 1 Mar 27 16:38 1
  6. c--------- 1 root root 5, 2 Jan 5 19:39 ptmx
  7. //继续登录终端
  8. [root@ht8 pts]# pwd
  9. /dev/pts
  10. [root@ht8 pts]# ll
  11. total 0
  12. crw--w---- 1 root tty 136, 0 Mar 27 2022 0
  13. crw--w---- 1 root tty 136, 1 Mar 27 16:38 1
  14. crw--w---- 1 root tty 136, 2 Mar 27 17:24 2 //新增加的终端
  15. c--------- 1 root root 5, 2 Jan 5 19:39 ptmx
  16. //主从关系
    [root@ht8 dev]# ls /dev/pt*
  17. /dev/ptmx /dev/pts0
  18. /dev/pts:
  19. 0 1 2 ptmx

[root@ht8 pts]# w

17:26:44 up 80 days, 20:48, 3 users, load average: 0.77, 0.65, 0.69
 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
 root pts/0 10.129.55.19 Sat10 4.00s 0.64s 0.00s w
 root pts/1 10.129.55.19 Sat20 48:04 0.04s 0.04s -bash
 root pts/2 10.129.55.19 17:24 2:35 0.02s 0.02s -bash

/dev/pts ( pseudo terminal slave) 副虚拟终端,其目录的文件都是由ptmx(主虚拟终端)产生的,它们是父子关系

当一个用户以ssh登录之后,该用户就分到一个ptmx所赋予的pts资源(pts/3),所以说ssh使用的是虚拟终端,不是真正的tty接口。telnet用的则是真正的tty接口。

[root@ht8 tmp]# ps -ef | grep pts  //3个终端
 root      37445   1377  0 Mar26 ?        00:00:00 sshd: root@pts/0
 root      37454  37445  0 Mar26 pts/0    00:00:00 -bash
 root     127715   1377  0 Mar26 ?        00:00:00 sshd: root@pts/1
 root     127736 127715  0 Mar26 pts/1    00:00:00 -bash
 root      53767   1377  0 17:24 ?        00:00:00 sshd: root@pts/2
 root      53776  53767  0 17:24 pts/2    00:00:00 -bash


devpts
文件系统 

  1. [root@ht8 dev]# df -ha |grep devpts
  2. devpts 0 0 0 - /dev/pts
  3.  
  4. [root@ht8 dev]# mount|column -t | grep devpts
  5. devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
  6.  
  7. //系统支持的文件
  8.  
  9. [root@ht8 ~]# cat /proc/filesystems
  10. nodev sysfs
  11. nodev rootfs
  12. nodev ramfs
  13. nodev bdev
  14. nodev proc
  15. nodev cgroup
  16. nodev cpuset
  17. nodev tmpfs
  18. nodev devtmpfs
  19. nodev debugfs
  20. nodev securityfs
  21. nodev sockfs
  22. nodev dax
  23. nodev bpf
  24. nodev pipefs
  25. nodev configfs
  26. nodev devpts
  27. nodev hugetlbfs
  28. nodev autofs
  29. nodev pstore
  30. nodev mqueue
  31. xfs
  32. nodev rpc_pipefs
  33. nodev nfs
  34. nodev nfs4
  35. nodev binfmt_misc
  36.  
  37. devpts 文件系统加载在 /dev/pts ,命令如下:
  38. mount devpts /dev/pts -t devpts
  1. 我们可以使用MAKEDEV来维护这个下面的设备文件,
  2. MAKEDEV 一个 脚本程序, 用于 /dev 目录下 建立 设备,
  3. 通过 这些 设备文件可以 访问 位于 内核 驱动程序.
  4. 注意, 如果 应用程序 显示 出错信息 ``ENOENT: No such file or directory'', 一般指 设备文件 不存在,
  5. `ENODEV: No such device'则 表明 内核 没有配置 或 装载 相应的 驱动程序.

5) 伪终端(/dev/pty)

  1. 这个是终端的发展,为满足现在需求(比如telnetxwindow窗口的管理)。伪终端(Pseudo Terminal)是成对的逻辑终端设备,
  2. 例如/dev/ptyp3和/dev/ttyp3(或着在设备文件系统中分别是/dev/pty/m3和/dev/pty/s3)。
  3.  
  4. 伪终端用于创建登陆会话或提供其它功能,比如通过 TTY line discipline (包括SLIP或者PPP功能)来处理任意的数据生成。每一个 PTY 都有一个master端和一个slave端。
    按照 System V/Unix98 PTY 命名方案,所有master端共享同一个 /dev/ptmx 设备节点(打开它内核将自动给出一个未分配的PTY),
    所有slave端都位于 /dev/pts 目录下,名为 /dev/pts/# (内核会根据需要自动生成和删除它们)。
  5. 它们与实际物理设备并不直接相关。如果一个程序把ttyp3看作是一个串 行端口设备,则它对该端口的读/写操作会反映在该逻辑终端设备对的另一个上面(ttyp3)。
  6. ttyp3则是 另一个程序用于读写操作的逻辑设备。这样,两个程序就可以通过这种逻辑设备进行互相交流,而其中
  7.  
  8. 一个使用ttyp3的程序则认为自己正在与一个串行端口进行通信。这很象是逻辑设备对之间的管道操作。
  9. 对于ttyp3s3),任何设计成使用一个串行端口设备的程序都可以使用该逻辑设备。但对于使用ptyp3
  10. 程序,则需要专门设计来使用ptyp3m3)逻辑设备。
  11. 例如,如果某人在网上使用telnet程序连接到你的计算机上,则telnet程序就可能会开始连接到设
  12. ptyp2m2)上(一个伪终端端口上)。此时一个getty程序就应该运行在对应的ttyp2s2)端口上。当telnet
  13. 远端获取了一个字符时,该字符就会通过m2s2传递给getty程序,而getty程序就会通过s2m2telnet程序
  14. 往网络上返回”login:”字符串信息。这样,登录程序与telnet程序就通过“伪终端”进行通信。通过使用适当的
  15. 软件,就可以把两个甚至多个伪终端设备连接到同一个物理串行端口上。
  16. 在使用设备文件系统(device filesystem)之前,为了得到大量的伪终端设备特殊文件,HP-UX AIX等使用了
  17. 比较复杂的文件名命名方式

6)/dev/console
是系统控制终端,系统的错误信息什么的都输出到这里,console是一个缓冲的概念,其实是为内核提供打印的。

我们的pc,终端常用的是显示器和键盘构成,我们用户打印和内核打印都从这个终端反映给用户。所以,这里,/dev/console是连接到/dev/tty0的,

其实这里有2个概念,console和tty这2个咚咚,怎么实现,其实console这个结构中有个device,这里其实就是tty0对应的一个虚拟终端设备。

如果,我们来个专门打印内核的设备(比如通过串口),我们把那个串口register_console,那么/dev/console就到这个串口设备了。

这时,内核打印就到这个串口设备了,而用户的打印还是和上面的/dev/tty相关,如果/dev/tty对应/dev/tty0,那么用户打印还在窗口中出现。

所以说/dev/console是用来外接控制台的。

然后在#dev/pts/0终端中输入echo"test">/dev/pts/0 结果另一个终端上回显示test。

然后你在#dev/pts/0终端中输入echo"test">/dev/tty, 你会发现在当前窗口也显示test字符串。也就是说dev/tty其实就是当前设备文件的一个链接。

关于/dev/console  应该来说更像一个缓冲结果吧,来实现对内核的打印,比如说内核把要打印的内容装入缓冲区,

然后由console来决定打印到哪里吧(比如是tty0还是串口等等吧)。

所以说/dev/console是用来外接控制台的。

  1. [root@ht8 src]# dmesg | grep tty*
  2. [ 0.000000] Found optimal setting for mtrr clean up
  3. [ 0.000000] Setting APIC routing to physical flat.
  4. [ 0.000000] console [tty0] enabled
  5. [ 0.137047] MDS: Vulnerable: Clear CPU buffers attempted, no microcode
  6. [ 0.193221] NMI watchdog: Shutting down hard lockup detector on all cpus
  7. [ 0.984859] pciehp 0000:00:15.0:pcie004: Slot #160 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  8. [ 0.984928] pciehp 0000:00:15.1:pcie004: Slot #161 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  9. [ 0.984989] pciehp 0000:00:15.2:pcie004: Slot #162 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  10. [ 0.985049] pciehp 0000:00:15.3:pcie004: Slot #163 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  11. [ 0.985109] pciehp 0000:00:15.4:pcie004: Slot #164 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  12. [ 0.985169] pciehp 0000:00:15.5:pcie004: Slot #165 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  13. [ 0.985229] pciehp 0000:00:15.6:pcie004: Slot #166 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  14. [ 0.985291] pciehp 0000:00:15.7:pcie004: Slot #167 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  15. [ 0.985353] pciehp 0000:00:16.0:pcie004: Slot #192 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  16. [ 0.985413] pciehp 0000:00:16.1:pcie004: Slot #193 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  17. [ 0.985475] pciehp 0000:00:16.2:pcie004: Slot #194 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  18. [ 0.985535] pciehp 0000:00:16.3:pcie004: Slot #195 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  19. [ 0.985595] pciehp 0000:00:16.4:pcie004: Slot #196 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  20. [ 0.985660] pciehp 0000:00:16.5:pcie004: Slot #197 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  21. [ 0.985723] pciehp 0000:00:16.6:pcie004: Slot #198 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  22. [ 0.985785] pciehp 0000:00:16.7:pcie004: Slot #199 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  23. [ 0.985846] pciehp 0000:00:17.0:pcie004: Slot #224 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  24. [ 0.985906] pciehp 0000:00:17.1:pcie004: Slot #225 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  25. [ 0.985966] pciehp 0000:00:17.2:pcie004: Slot #226 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  26. [ 0.986026] pciehp 0000:00:17.3:pcie004: Slot #227 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  27. [ 0.986087] pciehp 0000:00:17.4:pcie004: Slot #228 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  28. [ 0.986148] pciehp 0000:00:17.5:pcie004: Slot #229 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  29. [ 0.986210] pciehp 0000:00:17.6:pcie004: Slot #230 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  30. [ 0.986269] pciehp 0000:00:17.7:pcie004: Slot #231 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  31. [ 0.986329] pciehp 0000:00:18.0:pcie004: Slot #256 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  32. [ 0.986390] pciehp 0000:00:18.1:pcie004: Slot #257 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  33. [ 0.986450] pciehp 0000:00:18.2:pcie004: Slot #258 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  34. [ 0.986509] pciehp 0000:00:18.3:pcie004: Slot #259 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  35. [ 0.986569] pciehp 0000:00:18.4:pcie004: Slot #260 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  36. [ 0.986633] pciehp 0000:00:18.5:pcie004: Slot #261 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  37. [ 0.986699] pciehp 0000:00:18.6:pcie004: Slot #262 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  38. [ 0.986759] pciehp 0000:00:18.7:pcie004: Slot #263 AttnBtn+ PwrCtrl+ MRL- AttnInd- PwrInd- HotPlug+ Surprise- Interlock- NoCompl+ LLActRep+
  39. [ 0.987368] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
  40. [ 0.987372] ACPI: Power Button [PWRF]
  41. [ 1.001646] rtc_cmos 00:01: setting system clock to 2022-01-05 11:39:26 UTC (1641382766)
  42. [ 1.361181] mptsas: ioc0: attaching ssp device: fw_channel 0, fw_id 0, phy 0, sas_addr 0x5000c29f91edda54
  43. [ 1.372502] sd 2:0:0:0: [sda] Attached SCSI disk
  44. [ 1.483848] sd 0:0:1:0: [sdb] Attached SCSI disk
  45. [ 1.505423] sr 0:0:0:0: Attached scsi CD-ROM sr0
  46. [ 1.988570] SGI XFS with ACLs, security attributes, no debug enabled
  47. [ 12.918105] sd 2:0:0:0: Attached scsi generic sg0 type 0
  48. [ 12.918163] sr 0:0:0:0: Attached scsi generic sg1 type 5
  49. [ 12.918218] sd 0:0:1:0: Attached scsi generic sg2 type 0

设备标识会在/proc/devices下

  1. [root@ht8 src]# cat /proc/devices
  2. Character devices:
  3. 4 /dev/vc/0
  4. 4 tty
  5. 4 ttyS
  6. 5 /dev/tty
  7. 5 /dev/console
  8. 7 vcs
  9. 9 st
  10. 136 pts
  11. 252 rtc
  12. 253 dax
  13. ...

//我们在看下/dev下的有关tty,ttyS

  1. [root@ht8 src]# ll /dev/
  2. total 4
  3.  
  4. drwxr-xr-x 2 root root 3040 Mar 24 18:17 char
  5. lrwxrwxrwx 1 root root 15 Jan 5 19:39 stderr -> /proc/self/fd/2
  6. lrwxrwxrwx 1 root root 15 Jan 5 19:39 stdin -> /proc/self/fd/0
  7. lrwxrwxrwx 1 root root 15 Jan 5 19:39 stdout -> /proc/self/fd/1
  1. crw-rw-rw- 1 root tty 5, 0 Jan 5 19:39 tty
  2. crw--w---- 1 root tty 4, 0 Jan 5 19:39 tty0
  3. crw--w---- 1 root tty 4, 1 Mar 26 20:59 tty1
  4. crw--w---- 1 root tty 4, 10 Jan 5 19:39 tty10
  5. crw--w---- 1 root tty 4, 11 Jan 5 19:39 tty11
  6. crw--w---- 1 root tty 4, 12 Jan 5 19:39 tty12
  7. crw--w---- 1 root tty 4, 13 Jan 5 19:39 tty13
  8. crw--w---- 1 root tty 4, 14 Jan 5 19:39 tty14
  9. crw--w---- 1 root tty 4, 15 Jan 5 19:39 tty15
  10. crw--w---- 1 root tty 4, 16 Jan 5 19:39 tty16
  11. crw--w---- 1 root tty 4, 17 Jan 5 19:39 tty17
  12. crw--w---- 1 root tty 4, 18 Jan 5 19:39 tty18
  13. crw--w---- 1 root tty 4, 19 Jan 5 19:39 tty19
  14. crw--w---- 1 root tty 4, 2 Jan 5 19:39 tty2
  15. crw--w---- 1 root tty 4, 20 Jan 5 19:39 tty20
  16. crw--w---- 1 root tty 4, 21 Jan 5 19:39 tty21
  17. crw--w---- 1 root tty 4, 22 Jan 5 19:39 tty22
  18. crw--w---- 1 root tty 4, 23 Jan 5 19:39 tty23
  19. crw--w---- 1 root tty 4, 24 Jan 5 19:39 tty24
  20. crw--w---- 1 root tty 4, 25 Jan 5 19:39 tty25
  21. crw--w---- 1 root tty 4, 26 Jan 5 19:39 tty26
  22. crw--w---- 1 root tty 4, 27 Jan 5 19:39 tty27
  23. crw--w---- 1 root tty 4, 28 Jan 5 19:39 tty28
  24. crw--w---- 1 root tty 4, 29 Jan 5 19:39 tty29
  25. crw--w---- 1 root tty 4, 3 Jan 5 19:39 tty3
  26. crw--w---- 1 root tty 4, 30 Jan 5 19:39 tty30
  27. crw--w---- 1 root tty 4, 31 Jan 5 19:39 tty31
  28. crw--w---- 1 root tty 4, 32 Jan 5 19:39 tty32
  29. crw--w---- 1 root tty 4, 33 Jan 5 19:39 tty33
  30. crw--w---- 1 root tty 4, 34 Jan 5 19:39 tty34
  31. crw--w---- 1 root tty 4, 35 Jan 5 19:39 tty35
  32. crw--w---- 1 root tty 4, 36 Jan 5 19:39 tty36
  33. crw--w---- 1 root tty 4, 37 Jan 5 19:39 tty37
  34. crw--w---- 1 root tty 4, 38 Jan 5 19:39 tty38
  35. crw--w---- 1 root tty 4, 39 Jan 5 19:39 tty39
  36. crw--w---- 1 root tty 4, 4 Jan 5 19:39 tty4
  37. crw--w---- 1 root tty 4, 40 Jan 5 19:39 tty40
  38. crw--w---- 1 root tty 4, 41 Jan 5 19:39 tty41
  39. crw--w---- 1 root tty 4, 42 Jan 5 19:39 tty42
  40. crw--w---- 1 root tty 4, 43 Jan 5 19:39 tty43
  41. crw--w---- 1 root tty 4, 44 Jan 5 19:39 tty44
  42. crw--w---- 1 root tty 4, 45 Jan 5 19:39 tty45
  43. crw--w---- 1 root tty 4, 46 Jan 5 19:39 tty46
  44. crw--w---- 1 root tty 4, 47 Jan 5 19:39 tty47
  45. crw--w---- 1 root tty 4, 48 Jan 5 19:39 tty48
  46. crw--w---- 1 root tty 4, 49 Jan 5 19:39 tty49
  47. crw--w---- 1 root tty 4, 5 Jan 5 19:39 tty5
  48. crw--w---- 1 root tty 4, 50 Jan 5 19:39 tty50
  49. crw--w---- 1 root tty 4, 51 Jan 5 19:39 tty51
  50. crw--w---- 1 root tty 4, 52 Jan 5 19:39 tty52
  51. crw--w---- 1 root tty 4, 53 Jan 5 19:39 tty53
  52. crw--w---- 1 root tty 4, 54 Jan 5 19:39 tty54
  53. crw--w---- 1 root tty 4, 55 Jan 5 19:39 tty55
  54. crw--w---- 1 root tty 4, 56 Jan 5 19:39 tty56
  55. crw--w---- 1 root tty 4, 57 Jan 5 19:39 tty57
  56. crw--w---- 1 root tty 4, 58 Jan 5 19:39 tty58
  57. crw--w---- 1 root tty 4, 59 Jan 5 19:39 tty59
  58. crw--w---- 1 root tty 4, 6 Jan 5 19:39 tty6
  59. crw--w---- 1 root tty 4, 60 Jan 5 19:39 tty60
  60. crw--w---- 1 root tty 4, 61 Jan 5 19:39 tty61
  61. crw--w---- 1 root tty 4, 62 Jan 5 19:39 tty62
  62. crw--w---- 1 root tty 4, 63 Jan 5 19:39 tty63
  63. crw--w---- 1 root tty 4, 7 Jan 5 19:39 tty7
  64. crw--w---- 1 root tty 4, 8 Jan 5 19:39 tty8
  65. crw--w---- 1 root tty 4, 9 Jan 5 19:39 tty9
  1. crw-rw---- 1 root dialout 4, 64 Jan 5 19:39 ttyS0
  2. crw-rw---- 1 root dialout 4, 65 Jan 5 19:39 ttyS1
  3. crw-rw---- 1 root dialout 4, 66 Jan 5 19:39 ttyS2
  4. crw-rw---- 1 root dialout 4, 67 Jan 5 19:39 ttyS3
  5.  
  6. crw-rw---- 1 root tty 7, 0 Jan 5 19:39 vcs  
  7. crw-rw---- 1 root tty 7, 1 Jan 5 19:39 vcs1
  8. crw-rw---- 1 root tty 7, 2 Jan 5 19:39 vcs2
  9. crw-rw---- 1 root tty 7, 3 Jan 5 19:39 vcs3
  10. crw-rw---- 1 root tty 7, 4 Jan 5 19:39 vcs4
  11. crw-rw---- 1 root tty 7, 5 Jan 5 19:39 vcs5
  12. crw-rw---- 1 root tty 7, 6 Jan 5 19:39 vcs6
  13. crw-rw---- 1 root tty 7, 128 Jan 5 19:39 vcsa
  14. crw-rw---- 1 root tty 7, 129 Jan 5 19:39 vcsa1
  15. crw-rw---- 1 root tty 7, 130 Jan 5 19:39 vcsa2
  16. crw-rw---- 1 root tty 7, 131 Jan 5 19:39 vcsa3
  17. crw-rw---- 1 root tty 7, 132 Jan 5 19:39 vcsa4
  18. crw-rw---- 1 root tty 7, 133 Jan 5 19:39 vcsa5
  19. crw-rw---- 1 root tty 7, 134 Jan 5 19:39 vcsa6
    //
  1. //图形的VCS(“虚控制台屏幕”)VCSA的装置和(“具有属性虚拟控制台屏幕”)
  1. 例如/dev/vcs1/dev/vcsa1。的虚拟控制台可以在文件中被配置/etc/inittab读取由INIT -通常它启动几个虚拟控制台的文本模式登录过程getty

linux – tty,ttyS,pts,ptmx,vcs,vcsa设备文件之间的区别?(/dev/tty等)的更多相关文章

  1. [fw]Linux下tty/pty/pts/ptmx详解

    基本概念: 1> tty(终端设备的统称):tty一词源于Teletypes,或者teletypewriters,原来指的是电传打字机,是通过串行线用打印机键盘通过阅读和发送信息的东西,后来这东 ...

  2. Linux Shell脚本入门--(linux空设备文件和重定向)>/dev/null 2>&1

    linux空设备文件和重定向 输出/输入重导向 >      >>   <   <<   :>   &>   2&>   2< ...

  3. LINUX中块设备文件和字符设备文件的本质区别

    在LINUX系统文件类型分类的文章中我们提到了 块设备 和 字符设备文件,那么什么是块设备 字符设备文件呢?他们之间有什么本质上的区别呢? 设备文件分为 Block(块) Device Driver ...

  4. Linux文件描述符与打开文件之间的区别(转载)

    转载请说明出处:http://blog.csdn.net/cywosp/article/details/38965239   1. 概述     在Linux系统中一切皆可以看成是文件,文件又可分为: ...

  5. (转载)linux中设备文件配置程序udev详解

    如果你使用Linux比较长时间了,那你就知道,在对待设备文件这块,Linux改变了几次策略.在Linux早期,设备文件仅仅是是一些带有适当的属性集的普通文件,它由mknod命令创建,文件存放在/dev ...

  6. (转载)使用 udev 高效、动态地管理 Linux 设备文件

    概述: Linux 用户常常会很难鉴别同一类型的设备名,比如 eth0, eth1, sda, sdb 等等.通过观察这些设备的内核设备名称,用户通常能知道这些是什么类型的设备,但是不知道哪一个设备是 ...

  7. 嵌入式 使用udev高效、动态地管理Linux 设备文件

    本文以通俗的方法阐述 udev 及相关术语的概念.udev 的配置文件和规则文件,然后以 Red Hat Enterprise Server 为平台演示一些管理设备文件和查询设备信息的实例.本文会使那 ...

  8. 【转】使用 udev 高效、动态地管理 Linux 设备文件

    简介: 本文以通俗的方法阐述 udev 及相关术语的概念.udev 的配置文件和规则文件,然后以 Red Hat Enterprise Server 为平台演示一些管理设备文件和查询设备信息的实例.本 ...

  9. Linux学习之CentOS(六)---mount挂载设备(u盘,光盘,iso等 )

    对于新手学习,mount 命令,一定会有很多疑问.其实我想疑问来源更多的是对linux系统本身特殊性了解问题. linux是基于文件系统,所有的设备都会对应于:/dev/下面的设备.如: [cheng ...

随机推荐

  1. CF877F题解

    题目大意 有一个序列,每个位置上有 \(1\) 或 \(2\) 两种元素若干,每次询问一个区间,求这个区间有多少个子区间满足 \(1\) 类元素恰好比 \(2\) 类元素多 \(k\) 个. 莫队 要 ...

  2. 拉普拉斯特征映射(Laplacian Eigenmaps)

    1 介绍 拉普拉斯特征映射(Laplacian Eigenmaps)是一种不太常见的降维算法,它看问题的角度和常见的降维算法不太相同,是从局部的角度去构建数据之间的关系.也许这样讲有些抽象,具体来讲, ...

  3. chap8-fluent python

    浅拷贝 VS 深拷贝 # In[] # list 生成一个新的引用对象,只是用alst完成初始化 alst = [1,2,3,4,5] blst=list(alst) alst.append(6) p ...

  4. 线程池的极简用法——内置线程池multiprocessing

    大家好,今天博主来分享一个线程池的小捷径--内置线程池的使用方法 一.背景 说道多线程,对变成层有了解的小伙伴一定不陌生,虽然不知道是什么但是也会从各大网站.面试分享等途径听说过.这里就不做过多的介绍 ...

  5. 程序设计基础·Java学习笔记·面向对象(上)

    Java程序设计基础之面向对象(上) (自适应学习进度而进行记录的笔记,希望有一些小小的用处吧(^∀^●)ノシ) (新人上路,望多指教,如有错误,望指正,万分感谢(o゚v゚)ノ) 目录 一.面向对象 ...

  6. springWeb——Servlet

    6.1.Servlet简介 servlet是sun公司开发动态web的一门技术 sum在这些API中提供了一个接口叫做:Servlet.开发的两个步骤: 编写一个类,实现Servlet接口 把开发好的 ...

  7. windows服务器怎么将证书添加到受信任证书颁发机构

    1.键盘输入win+r 快键键,出现运行,输入mmc. 2.打开控制台根节点,点击上方导航栏的文件-->添加删除管理单元.如下图. 3.在可用的管理单元中选择"证书",计算机 ...

  8. 内网渗透----windows信息收集整理

    一.基础信息收集 1.信息收集类型 操作系统版本.内核.架构 是否在虚拟化环境中,已安装的程序.补丁 网络配置及连接 防火墙设置 用户信息.历史纪录(浏览器.登陆密码) 共享信息.敏感文件.缓存信息. ...

  9. 盘点几种DIY加密狗的制作方法,适用于穿越机模拟器

    前言 前几天笔者的加密狗在使用中突然坏掉了,现象是插电脑不识别,LED灯不亮. 网上很多模友也反映了同样的问题: http://bbs.5imx.com/forum.php?mod=viewthrea ...

  10. Flutter入门教程(一)Flutter简介

    这是Flutter系列第一篇文章,后续会持续更新Flutter相关知识,本篇就主要对于Flutter技术做一个简单的入门介绍 一.Flutter简介 Flutter是谷歌的移动UI框架,可以快速在iO ...