打开3个bash会话窗口 

[root@server1 fd]# cd /proc/7489/fd
[root@server1 fd]# ll
总用量 0
lrwx------ 1 root root 64 6月 5 23:55 0 -> /dev/pts/2
lrwx------ 1 root root 64 6月 5 23:55 1 -> /dev/pts/2
lrwx------ 1 root root 64 6月 5 23:55 2 -> /dev/pts/2
lrwx------ 1 root root 64 6月 5 23:55 255 -> /dev/pts/2
[root@server1 fd]# cd /proc/7508/fd
[root@server1 fd]# ll
总用量 0
lrwx------ 1 root root 64 6月 5 23:55 0 -> /dev/pts/3
lrwx------ 1 root root 64 6月 5 23:55 1 -> /dev/pts/3
lrwx------ 1 root root 64 6月 5 23:55 2 -> /dev/pts/3
lrwx------ 1 root root 64 6月 5 23:55 255 -> /dev/pts/3
[root@server1 fd]# cd /proc/6734/fd
[root@server1 fd]# ll
总用量 0
lrwx------ 1 root root 64 6月 5 23:56 0 -> /dev/pts/0
lrwx------ 1 root root 64 6月 5 23:56 1 -> /dev/pts/0
lrwx------ 1 root root 64 6月 5 23:56 2 -> /dev/pts/0
lrwx------ 1 root root 64 6月 5 23:56 255 -> /dev/pts/0

 

[root@server1 fd]# cd /dev/pts
[root@server1 pts]# ll
总用量 0
crw--w---- 1 root tty 136, 0 6月 5 18:26 0
crw--w---- 1 root tty 136, 1 6月 5 23:57 1
crw--w---- 1 root tty 136, 2 6月 5 23:54 2
crw--w---- 1 root tty 136, 3 6月 5 23:55 3
c--------- 1 root root 5, 2 5月 16 16:23 ptmx

[root@server1 pts]# tty
/dev/pts/1

[root@server1 ~]# tty
/dev/pts/2

[root@server1 ~]# tty
/dev/pts/3

tty:命令

tty - print the file name of the terminal connected to standard input

创健6个可切换终端:


root 1019 1 0 May16 tty1 00:00:00 /sbin/mingetty /dev/tty1
root 1021 1 0 May16 tty2 00:00:00 /sbin/mingetty /dev/tty2
root 1023 1 0 May16 tty3 00:00:00 /sbin/mingetty /dev/tty3
root 1025 1 0 May16 tty4 00:00:00 /sbin/mingetty /dev/tty4
root 1027 1 0 May16 tty5 00:00:00 /sbin/mingetty /dev/tty5
root 1029 1 0 May16 tty6 00:00:00 /sbin/mingetty /dev/tty6

ALT +F[1-6]切换,

[root@localhost dev]# tty
  /dev/pts/1

[root@localhost dev]# echo "0" > /dev/tty0

所有的tty[1-6]都显示 0

1 当前控制终端(/dev/tty)
/dev/tty指的是当前所处的终端,输出到此的内容只会显示在当前工作的终端显示器上;可以使用命令”ps –ax”来查看进程与哪个控制终端相连.对于你登录的shell,
/dev/tty就是你使用的终端,设备号是(5,0).
使用命令”tty”可以查看自己具体对应哪个实际终端设备./dev/tty有些类似于到实际所使用终端设备的一个联接 2./dev/pts
/dev/pts是远程登陆(telnet,ssh等)后创建的控制台设备文件所在的目录。由于可能有好几千个用户登陆,所以/dev/pts其实是动态生成的,不象其他设备文件是构建系统时就已经产生的硬盘节点. 3.控制台终端-系统控制台(/dev/console 和 /dev/tty*)
Linux系统中,计算机显示器通常被称为控制台终端(Console).它仿真了类型为Linux的一种终端(TERM=Linux),并且有一些设备特殊文件与之相关联:
tty0、tty1、tty2等.当你在控制台上登录时,使用的是tty1.使用Alt+[F1—F6]组合键时,我们就可以切换到tty2、tty3等上面去.tty1–tty6等称为虚拟终端
而tty0则是当前所使用虚拟终端的一个别名,系统所产生的信息会发送到该终端上.因此不管当前正在使用哪个虚拟终端,系统信息都会发送到控制台终端上.
你可以登录到不同的虚拟终端上去,因而可以让系统同时有几个不同的会话期存在.只有系统或超级用户root可以向/dev/tty0进行写操作.

root 4665 925 0 13:53 ? 00:00:00 sshd: root@pts/0
root 4667 4665 0 13:53 pts/0 00:00:00 -bash
root 4744 925 0 14:53 ? 00:00:00 sshd: root@pts/1
root 4746 4744 0 14:53 pts/1 00:00:00 -bash
root 4843 925 0 16:24 ? 00:00:00 sshd: root@pts/2
root 4845 4843 0 16:24 pts/2 00:00:00 -bash
root 4860 925 0 16:24 ? 00:00:00 sshd: root@pts/3
root 4862 4860 0 16:24 pts/3 00:00:00 -bash
root 4877 925 0 16:24 ? 00:00:00 sshd: root@pts/4
root 4879 4877 0 16:24 pts/4 00:00:00 -bash
root 4894 925 0 16:24 ? 00:00:00 sshd: root@pts/5
root 4896 4894 0 16:24 pts/5 00:00:00 -bash
root 4911 925 0 16:25 ? 00:00:00 sshd: root@pts/6
root 4913 4911 0 16:25 pts/6 00:00:00 -bash
root 4935 925 0 16:25 ? 00:00:00 sshd: root@pts/7
root 4937 4935 0 16:25 pts/7 00:00:00 -bash
root 4954 925 0 16:25 ? 00:00:00 sshd: root@pts/8

[root@server1 ~]# cd /dev/pts
[root@server1 pts]# ll
总用量 0
crw--w---- 1 root tty 136, 0 6月 4 16:25 0
crw--w---- 1 root tty 136, 1 6月 4 16:25 1
crw--w---- 1 root tty 136, 2 6月 4 16:25 2
crw--w---- 1 root tty 136, 3 6月 4 16:25 3
crw--w---- 1 root tty 136, 4 6月 4 16:25 4
crw--w---- 1 root tty 136, 5 6月 4 16:25 5
crw--w---- 1 root tty 136, 6 6月 4 16:25 6
crw--w---- 1 root tty 136, 7 6月 4 16:25 7
crw--w---- 1 root tty 136, 8 6月 4 16:28 8
c--------- 1 root root 5, 2 5月 16 16:23 ptmx


linux下看到的控制台(console)是由几个设备完成的。分别是/dev/ttyN(其中tty0就是/dev/console,tty1,tty2就是不同的虚拟终端(virtual console))
通常使用热键alt+Fn来在这些虚拟终端之间进行切换。所有的这些tty设备都是由linux/drivers/char /console.c和vt.c对应。
ALT+F7切回到GUI桌面
动态创健/dev/pts:

root@server1 ~]# cd /dev/pts
[root@server1 pts]# ll
总用量
crw--w---- root tty , 6月 :
crw--w---- root tty , 6月 :
c--------- root root , 5月 : ptmx [root@server1 pts]# ll
总用量
crw--w---- root tty , 6月 :
c--------- root root , 5月 : ptmx


alt+[F1-F6] 进行切换 :当前切换为:alt+F5
[root@server1 dev]# cd pts
[root@server1 pts]# ll
总用量
crw--w---- root tty , 6月 :
crw--w---- root tty , 6月 :
c--------- root root , 5月 : ptmx pts+ptmx 实现tty登陆
init 1进入单用户: tty为 /dev/console

/dev/tty 与 /dev/pts的更多相关文章

  1. linux – tty,ttyS,pts,ptmx,vcs,vcsa设备文件之间的区别?(/dev/tty等)

    linux – tty,ttyS,pts,ptmx,vcs,vcsa设备文件之间的区别? 终端有字符终端和图形终端两种模式.在linux的图形环境下,我们可以通过鼠标点击来完成所有的管理任务,这是图形 ...

  2. /dev/console,/dev/null,/dev/tty

    UNIX和Linux中比较重要的三个设备文件是:/dev/console,/dev/tty和/dev/null. 0 :  /dev/console 这个设备代表的是系统控制台,错误信息和诊断信息通常 ...

  3. centos单用户 救援 运行级别 yum,单用户模式,救援模式,inittab :启动级别 e2fsck wetty mingetty 物理终端 /dev/console 虚拟终端 /dev/tty(0,6) 模拟终端 /dev/pts/# grub-md5-crypt 给grub加密码 initrd 第二节课

    centos单用户 救援 运行级别  yum,单用户模式,救援模式,inittab :启动级别  e2fsck  wetty  mingetty  物理终端 /dev/console  虚拟终端 /d ...

  4. /dev/tty /dev/ttyS0 /dev/tty0,/dev/null区别

    1./dev/tty表示控制终端如果当前进程有控制终端(Controlling Terminal)的话,那么/dev/tty就是当前进程的控制终端的设备特殊文件.可以使用命令”ps –ax”来查看进程 ...

  5. 特殊文件: /dev/null和/dev/tty

    转自:http://www.cnblogs.com/stephen-liu74/archive/2011/11/10/2240461.html Linux系统提供了两个对Shell编程非常有用的特殊文 ...

  6. /dev/tty /dev/ttyS0 /dev/tty0区别 (转载)

    1.串行端口终端(/dev/ttySn)     串行端口终端(Serial Port Terminal)是使用计算机串行端口连接的终端设备.    计算机把每个串行端口都看作是一个字符设备.有段时间 ...

  7. What is special about /dev/tty?

    ls -la /dev/tty shows the output: crw-rw-rw- 1 root tty 5, 0 Dec 14 22:21 /dev/tty The 'c' means it' ...

  8. 2.5.5.2 特殊文件:/dev/null 与 /dev/tty

        UNIX 系统提供了两个对Shell编程特别有用的特殊文件.       第一个文件 /dev/null ,就是大家所熟知的位桶(bit bucket).传送到此文件的数据都会被丢掉.换句话说 ...

  9. hostapd、/dev/random、/dev/urandom

    在使用hostapd做软ap时,出现了random熵不够的问题,导致节点连接不上这个ap. 下面先解释一下/dev/random和/dev/urandom 先让我们从一个工程中遇到的实际问题开始,先上 ...

随机推荐

  1. 第 16 章 观察者模式【Observer Pattern】

    以下内容出自:<<24种设计模式介绍与6大设计原则>> <孙子兵法>有云:“知彼知己,百战不殆:不知彼而知己,一胜一负:不知彼,不知己,每战必殆”,那怎么才能知己知 ...

  2. SQL 维护用得到的监控语句

    使用DMV来分析SQL Server启动以来累计使用CPU资源最多的语句.例如下面的语句就可以列出前50名 s2.dbid, ( , ( ( ) )) AS sql_statement, execut ...

  3. hdu 1875

    题目很简单,我却WA了几十次,找错误找了我一个小时: 蛋都碎了! 后来发现错误的地方竟然是memset: 用一个循环来替代它就A了:╮(╯▽╰)╭ 今晚回去好好的看看memset!!! 发个代码纪念下 ...

  4. SSH框架是个怎么回事?

    我相信来看这篇文章的童鞋基本上是刚开始入门正在努力找方向的,所以我将尽可能的少涉及旁枝末节及背景知识,力求简明易懂.当然高手们如果在读了小文之后发现了任何错误和不妥,请不吝指正. 直接进入正题.现在我 ...

  5. PYTHON连MS SQL示例

    先要设置WINDOWS的系统DSN的.然后才可以哟. import pyodbc conxn = pyodbc.connect('DSN=BBB; DATABASE=Northwind;UID=AAA ...

  6. Spring In Action 第4版笔记-第一章-001架构

    1.Spring’s fundamental mission: Spring simplifies Java development. 2.To back up its attack on Java ...

  7. OA学习笔记-005-Spring2.5与struts2.1整合

    一.单独测试strust 1.action package cn.itcast.oa.test; import org.springframework.context.annotation.Scope ...

  8. ANDROID_MARS学习笔记_S04_001_OAuth简介

    一.OAuth简介

  9. Process.RedirectStandardInput

    获取或设置一个值,该值指示应用程序的输入是否从 Process.StandardInput 流中读取. 命名空间:System.Diagnostics程序集:System(在 system.dll 中 ...

  10. SIFT算法:特征描述子

    SIFT算法:DoG尺度空间生产  SIFT算法:KeyPoint找寻.定位与优化 SIFT算法:确定特征点方向  SIFT算法:特征描述子 目录: 1.确定描述子采样区域 2.生成描述子 2.1 旋 ...