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's a character device. tty is a special file representing the 'controlling terminal' for the current process.

Character Devices

Unix supports 'device files', which aren't really files at all, but file-like access points to hardware devices. A 'character' device is one which is interfaced byte-by-byte (as opposed to buffered IO).

TTY

/dev/tty is a special file, representing the terminal for the current process. So, when you echo 1 > /dev/tty, your message ('1') will appear on your screen. Likewise, when you cat /dev/tty, your subsequent input gets duplicated (until you press Ctrl-C).

/dev/tty doesn't 'contain' anything as such, but you can read from it and write to it (for what it's worth). I can't think of a good use for it, but there are similar files which are very useful for simple IO operations (e.g. /dev/ttyS0 is normally your serial port)

linux用户登录有三种方式:

(1)命令行登录:init进程调用getty程序(意为get teletype),让用户输入用户名和密码。输入完成后,再调用login程序,核对密码(Debian还会再多运行一个身份核对程序/etc/pam.d/login)。如果密码正确,就从文件 /etc/passwd 读取该用户指定的shell,然后启动这个shell。

(2)ssh登录:这时系统调用sshd程序(Debian还会再运行/etc/pam.d/ssh ),取代getty和login,然后启动shell。

(3)图形界面登录:init进程调用显示管理器,Gnome图形界面对应的显示管理器为gdm(GNOME Display Manager),然后用户输入用户名和密码。如果密码正确,就读取/etc/gdm3/Xsession,启动用户的会话。

original from: http://stackoverflow.com/questions/8514735/what-is-special-about-dev-tty

http://www.ruanyifeng.com/blog/2013/08/linux_boot_process.html

What is special about /dev/tty?的更多相关文章

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

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

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

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

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

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

  4. /dev/tty 与 /dev/pts

     打开3个bash会话窗口  [root@server1 fd]# cd /proc/7489/fd[root@server1 fd]# ll总用量 0lrwx------ 1 root root 6 ...

  5. /dev/console,/dev/null,/dev/tty

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

  6. 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 ...

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

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

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

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

  9. unable to read askpass response from 'C:\Users\wxy\.IntelliJIdea2019.1\system\tmp\intellij-git-askpass.bat' bash: /dev/tty: No such device or address failed to execute prompt script (exit code 1)

    解决方法:

随机推荐

  1. MyBatis学习-偏实践(单独MyBatis项目)

    准备先把MyBatis搞熟悉了,然后把SpringMVC搞熟悉了. MyBatis的材料,除了我之前自己实验的 http://www.cnblogs.com/charlesblc/p/5906431. ...

  2. 防止木马利用iframe框架来调用外域JS代码

    <!--防止木马利用iframe框架来调用外域JS代码,不过滤自己网站的域名的框架网页开始--><SCRIPT LANGUAGE="JavaScript"> ...

  3. linux基础-第十八单元_nginx部署

    一.基本环境配置 1.1.安装常用软件 yum install wget -y 1.2.Install yum repo mv /etc/yum.repos.d/CentOS-Base.repo /e ...

  4. pymongo增删查改以及条件查询

    ---恢复内容开始--- 下载Pymongo pip install pymongo pip install pymongo==x.x.x指定下载版本 连接数据库 from pymongo impor ...

  5. 奇特的JavaScript连续赋值运算

    一.引子: }; a.x = a = {n:}; alert(a.x); // --> undefined 以上第二句 a.x = a = {n:2} 是一个连续赋值表达式.这个连续赋值表达式在 ...

  6. SSH V2的中间人攻击

    SSH V2的中间人攻击 2012-12-19 10:48:52     我来说两句      作者:Dis9Team 收藏    我要投稿 中间人攻击(Man-in-the-MiddleAttack ...

  7. ColorSchemer Studio 2 破解

    软件介绍: ColorSchemer Studio 2 is a professional color matching application for anyone from hobbyists t ...

  8. ScrollView反弹效果

    public class BounceScrollView extends ScrollView { private View inner;// 孩子View private float y;// 点 ...

  9. hdu1010 dfs+路径剪枝

    题意:用一个案例来解释 4 4 5 S.X. ..X. ..XD .... 在这个案例中,是一个4*4的地图. . 表示可走的地方, X 表示不可走的地方,S表示起始点,D表示目标点.没走到一个点之后 ...

  10. 《windows核心编程》- 线程栈

    当系统创建线程的时候,会为线程栈预订一块地址空间区域,并给该区域调拨一些物理存储器.默认会预订1MB的地址空间并调拨两个页面的存储器.但是在构建 应用程序的时候可以改变这个默认值 在构建应用程序的时候 ...