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

最新文章

  1. ubuntu下rhythmbox歌名显示乱码问题解决
  2. iOS企业级开发
  3. 深入浅出Zookeeper
  4. open files
  5. VC中遍历进程并获取进程信息
  6. JavaEE学习之类加载器
  7. URL加随机数的作用
  8. 输入框 js正则推断输入
  9. js菜鸟进阶-jQuery源码分析(1)-基本架构
  10. Maven(五)之Maven配置阿里云镜像飞快下jar包
  11. Springboot-shiro-redis实现登录认证和权限管理
  12. 使用Apache的ab进行压力测试
  13. 【BZOJ 4016】 [FJOI2014]最短路径树问题
  14. PHP代码审计之XSS操作
  15. python之路3-元组、列表、字典、集合
  16. Docker Mysql数据库主从同步配置方法
  17. 从原型链看DOM--Node类型
  18. php 网站301重定向设置代码实战案例
  19. Tomcat中的session实现
  20. fifo 上使用 select -- 转

热门文章

  1. javascript快速入门24--XML基础
  2. CreatarGlobe实现多机立体显示方案(初稿)
  3. 五子棋js
  4. LintCode - Merge Two Sorted List
  5. 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-如何获取标准驱动器扭矩值获取电流值
  6. Java8 CompletableFuture组合式的编程(笔记)
  7. sql中limit和汇总函数的集合使用
  8. SoC嵌入式软件架构设计之六:API设计方法
  9. java之生成jar包
  10. node-webkit 开发环境搭建