terminal(终端),shell,tty,console(控制台)区别
原文地址 stackexchange:What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?
(原文wiki链接在翻译中替换为百度百科链接。)
A terminal is at the end of an electric wire, a shell is the home of a turtle, tty is a strange abbreviation and a console is a kind of cabinet.
终端在电线的末端,壳是乌龟的家,tty是一个奇怪的缩写,控制台是一种柜子。
Well, etymologically speaking, anyway.
从词源学上讲,是这样。
In unix terminology, the short answer is that
在unix术语中,简短地回答是:
- terminal = tty = text input/output environment
- console = physical terminal
- shell = command line interpreter
- terminal(终端) = tty = 文本输入/输出环境
- console(控制台) = 物理终端
- shell(壳) = 命令行解释器
Console, terminal and tty are closely related. Originally, they meant a piece of equipment through which you could interact with a computer: in the early days of unix, that meant a teleprinter-style device resembling a typewriter, sometimes called a teletypewriter, or “tty” in shorthand. The name “terminal” came from the electronic point of view, and the name “console” from the furniture point of view. Very early in unix history, electronic keyboards and displays became the norm for terminals.
控制台,终端和tty联系密切。最初,它们代表一台可以与计算机进行交互的设备:在unix的早期,它代表(teleprinter)电传打字机-外形类似打印机,也叫teletypewriter,或者缩写为"tty"。“终端”是从电子的角度看,“控制台”是从设备的角度看。在unxi的最初阶段,键盘和显示器成为终端的标准。
In unix terminology, a tty is a particular kind of device file which implements a number of additional commands (ioctls) beyond read and write. In its most common meaning, terminal is synonymous with tty. Some ttys are provided by the kernel on behalf of a hardware device, for example with the input coming from the keyboard and the output going to a text mode screen, or with the input and output transmitted over a serial line. Other ttys, sometimes called pseudo-ttys, are provided (through a thin kernel layer) by programs called terminal emulators, such as Xterm (running in the X Window System), Screen (which provides a layer of isolation between a program and another terminal), Ssh(which connects a terminal on one machine with programs on another machine), Expect (for scripting terminal interactions), etc.
在unxi术语中,tty是一种特殊的设备文件,它实现了一些额外的读写命令(ioctls,io设备控制函数)。一般,终端与tty同义。内核提供了一些代表硬件设备的tty,例如来自键盘的输入和到文本模式屏幕的输出,或在串行上传输的输入输出流。另一种tty,有时也被称为伪tty,是通过终端模拟器程序提供的(通过一个核心层),终端模拟器程序包括如Xterm(运行在X Windox System),Screen(提供了一个程序与另一个终端之间的独立中间层),SSH(在一台机器上连接另一台机器的终端的程序),Expect(脚本终端交互)等等。
The word terminal can also have a more traditional meaning of a device through which one interacts with a computer, typically with a keyboard and display. For example an X terminal is a kind of thin client, a special-purpose computer whose only purpose is to drive a keyboard, display, mouse and occasionally other human interaction peripherals, with the actual applications running on another, more powerful computer.
terminal这个词还有一个更传统的意思,它表示一台可以与计算机交互的设备,通常是键盘和屏幕。例如X terminal是一种瘦客户端,瘦客户端是一种特殊用途的计算机,它的唯一目的是驱动键盘,显示器,鼠标以及一些其它的人机交互外设,实际的程序运行在另一台更强大的计算机上。
A console is generally a terminal in the physical sense that is by some definition the primary terminal directly connected to a machine. The console appears to the operating system as a (kernel-implemented) tty. On some systems, such as Linux and FreeBSD, the console appears as several ttys (special key combinations switch between these ttys); just to confuse matters, the name given to each particular tty can be “console”, ”virtual console”, ”virtual terminal”, and other variations.
控制台通常是物理意义上的终端,一个直接连接到机器上的主终端。控制台在操作系统上通常表现为一个(内核实现的)tty。在一些系统中,如Linux和FreeBSD,控制台表现为多个tty(通过特定的组合键在tty之间切换),让人混乱的是,每个特定的tty的名称可以是"console"(控制台),"virtual terminal"(虚拟终端)等等。
See also Why is a Virtual Terminal “virtual”, and what/why/where is the “real” Terminal?.
参考Why is a Virtual Terminal “virtual”, and what/why/where is the “real” Terminal?.
A shell is the primary interface that users see when they log in, whose primary purpose is to start other programs. (I don't know whether the original metaphor is that the shell is the home environment for the user, or that the shell is what other programs are running in.)
shell(壳)是用户登录系统时看到的主界面,它主要的作用是启动其它程序。(我不知道原来的喻义是指shell是用户的home环境,还是shell是其它程序的运行环境。)
In unix circles, shell has specialized to mean a command-line shell, centered around entering the name of the application one wants to start, followed by the names of files or other objects that the application should act on, and pressing the Enter key. Other types of environments don't use the word “shell”; for example, window systems involve “window managers” and “desktop environments”, not a “shell”.
在unix圈中,shell特指命令行shell,围绕输入想要启动的程序名称,后面跟着文件名或者其它应用程序需要知道的东西,然后按回车键。其它类型的环境不使用"shell"这个词;例如,窗口系统包括"窗口管理器"和"桌面环境",而不是"shell"。
There are many different unix shells. Popular shells for interactive use include Bash (the default on most Linux installations), zsh (which emphasizes power and customizability) and fish (which emphasizes simplicity).
有很多不同的unix shell。流行的交互式shell包括Bash(大多数Linux默认安装),zsh(注重功能和可定制性),fish(注重简单)。
Command-line shells include flow control constructs to combine commands. In addition to typing commands at an interactive prompt, users can write scripts. The most common shells have a common syntax based on the Bourne_shell. When discussing “shell programming”, the shell is almost always implied to be a Bourne-style shell. Some shells that are often used for scripting but lack advanced interactive features include the Korn shell (ksh) and many ash variants. Pretty much any Unix-like system has a Bourne-style shell installed as /bin/sh, usually ash, ksh or bash.
命令行shell包括了组合命令的流程控制结构。除了在交互式提示符中键入命令外,用户还可以编写脚本。大多数shell使用一套基于Bourne_shell的语法。当讨论"shell编程"是,shell通常指Bourne-shell风格的shell。一些shell经常用来运行脚本但是缺少高级的交互特性,包括the Korn shell(ksh)和ash的变种。几乎所有的类Unix系统都有一个Bourne-style的shell安装在/bin/sh,通常是ash,ksh或者bash。
In unix system administration, a user's shell is the program that is invoked when they log in. Normal user accounts have a command-line shell, but users with restricted access may have a restricted shell or some other specific command (e.g. for file-transfer-only accounts).
在unix系统管理中,一个用户的shell是指他们登录时被调用的程序。普通用户拥有一个命令行shell,但限制权限的用户会拥有一个restricted shell或者只能运行特定命令的shell(如仅用于文件传输的账户)。
The division of labor between the terminal and the shell is not completely obvious. Here are their main tasks.
terminal(终端)和shell的分工并不十分明显。它们的主要任务:
- Input: the terminal converts keys into control sequences (e.g. Left →
\e[D). The shell converts control sequences into commands (e.g.\e[D→backward-char). - 输入:terminal将键盘操作转换为控制序列(如 Left -> \e[D)。shell将控制序列转换为命令(如 \e[D -> backward-char)。
- Line edition, input history and completion are provided by the shell.
- The terminal may provide its own line edition, history and completion instead, and only send a line to the shell when it's ready to be executed. The only common terminal that operates in this way is
M-x shellin Emacs.
- The terminal may provide its own line edition, history and completion instead, and only send a line to the shell when it's ready to be executed. The only common terminal that operates in this way is
- 行编辑,输入历史和补全是shell提供的。
- terminal可能会提供自己的行编辑,输入历史和补全,并且只在准备执行命令的时候将命令发送给shell。主流的terminal中唯一这样做的是Emacs中的M-x shell。
- Output: the shell emits instructions such as “display
foo”, “switch the foreground color to green”, “move the cursor to the next line”, etc. The terminal acts on these instructions. - 输出:shell发出指令如"display foo", “switch the foreground color to green”, “move the cursor to the next line”等,终端响应这些指令。
- The prompt is purely a shell concept.
- 提示符是shell中的概念。
- The shell never sees the output of the commands it runs (unless redirected). Output history (scrollback) is purely a terminal concept.
- shell中看不到它运行的命令的输出(除非重定向)。输出历史(回滚)是terminal中的概念。
- Inter-application copy-paste is provided by the terminal (usually with the mouse or key sequences such as Ctrl+Shift+V or Shift+Insert). The shell may have its own internal copy-paste mechanism as well (e.g. Meta+W and Ctrl+Y).
- 应用程序之间的复制粘贴是terminal提供的(通常用鼠标或键盘组合如: Ctrl+Shift+V 或 Shift+Insert)。shell也有自己的内部复制粘贴机制(如 Meta+W and Ctrl+Y)。
- Job control (launching programs in the background and managing them) is mostly performed by the shell. However, it's the terminal that handles key combinations like Ctrl+C to kill the foreground job and Ctrl+Z to suspend it.
- 作业控制(在后台启动程序并管理程序)主要有shell执行。然而,terminal处理组合键如Ctrl+C 来终止前台程序, Ctrl+Z来挂起前台程序。
扩展阅读:
CSDN:控制台,终端,虚拟终端,tty,shell等概念的区别
terminal(终端),shell,tty,console(控制台)区别的更多相关文章
- 【转】控制台,终端,tty,shell等概念的区别
转自:http://www.2cto.com/os/201403/282583.html http://blog.sina.com.cn/s/blog_bcdac52b0101i2r1.html 控制 ...
- 命令行界面 (CLI)、终端 (Terminal)、Shell、TTY的区别
虽然这个话题已是老生常谈,搜索一下应该也能找到大把的相关文章.不过难得提到了这方面,就趁此机会把我的理解写下来,一来看看我是不是真正理解了,二来看看我能不能把它们之间的区别讲得更加简明易懂. 0. 太 ...
- 【转】linux下tty,控制台,虚拟终端,串口,console(控制台终端)详解----不错
原文网址:http://blog.csdn.net/liaoxinmeng/article/details/5004743 首先: 1.终端和控制台都不是个人电脑的概念,而是多人共用的小型中型大型计算 ...
- Linux中终端和控制台区别
Linux中终端和控制台区别: 终端:英文名叫terminal 控制台:英文名叫console 两者区别要从以前的多人使用的计算机开始 以前,由于计算机很昂贵,所用一台计算机一般由多个人同时使用.这样 ...
- (Linux基础学习)第三章:terminal与shell的简介和修改命令提示符颜色
第1节:terminal终端设备终端:键盘.鼠标.显示器物理终端(/dev/console):控制台console虚拟终端(tty:teletypewriters,/dev/tty# #为[1-6]) ...
- Firebug & Chrome Console 控制台使用指南
转自:http://visionsky.blog.51cto.com/733317/543789 Console API 当打开 firebug (也包括 Chrome 等浏览器的自带调试工具),wi ...
- eclipse中的Console控制台视图脱离主窗口解决办法
问题:Console控制台视图由于操作不当,跑出来了,脱离了主窗口 解决:在eclipse主窗口最上面的工具条选项中,找到Window,点击里面的Reset Perspective,即可,这样视图就重 ...
- phpStorm如何在Console控制台执行php文本,而不是浏览器中
如何在Console控制台执行php文本 phpStorm默认会在浏览器中执行脚本 默认的配置 配置PHP脚本 扩展,配置项目运行
- console控制台的小问题
第一个foo里面应该是123,但是当执行完下面的代码之后,console控制台会自动将里面的内容改成我们修改之后的
随机推荐
- loj 1251(2-sat + 输出一组可行解)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26961 思路:u表示留下,~u表示离开,同理v,对于+u,-v,我 ...
- 获取表信息(MSSQL)
涉及到的系统表汇总 sys.databases sys.objects sys.indexes sys.tables sys.columns sys.data_spaces sys.partition ...
- &1的用法
看到不少大神都喜欢用&1来判断一些东西,但是作为渣渣的我总是不理解这个&1到底是有什么作用. 今天写了程序看了一下,其实是判断奇偶用的. 如果是奇数,其结果为1,偶数结果为false. ...
- js:语言精髓笔记2--表达式
表达式:由运算符和运算元构成:JS中没有运算符的表达式称为单值表达式:没有运算元,孤立与代码上下文的运算符是不符合语法的:(表达式是有返回值的) 单值表达式: this引用: 变量引用: 直接量: n ...
- JQuery LazyLoad实现图片延迟加载-探究
对于大量图片的网站,图片延迟加载是提高速度和性能的好方法. 目前图片延迟加载主要分两大块,一是触发加载(根据滚动条位置加载图片):二是自动预加载(加载完首屏后n秒后自动加载其他位置的图片).大体常用的 ...
- TYVJ P1004 滑雪 Label:记忆化搜索
背景 成成第一次模拟赛 第三道 描述 trs喜欢滑雪.他来到了一个滑雪场,这个滑雪场是一个矩形,为了简便,我们用r行c列的矩阵来表示每块地形.为了得到更快的速度,滑行的路线必须向下倾斜. ...
- 洛谷 P1541 乌龟棋 Label:O(n^4)的dp
题目背景 小明过生日的时候,爸爸送给他一副乌龟棋当作礼物. 题目描述 乌龟棋的棋盘是一行N个格子,每个格子上一个分数(非负整数).棋盘第1格是唯一的起点,第N格是终点,游戏要求玩家控制一个乌龟棋子从起 ...
- 【BZOJ】1098: [POI2007]办公楼biu(补图+bfs+链表)
http://www.lydsy.com/JudgeOnline/problem.php?id=1098 显然答案是补图连通块..... 想到用并查集...可是连补图的边都已经...n^2了...怎么 ...
- 【POJ】1062 昂贵的聘礼(spfa)
http://poj.org/problem?id=1062 此题一开始果断想到暴力.. 但是n<=100果断不行. 一看题解,噗!最短路... 构图很巧妙. 每一个物品对应的所需物品相当于一个 ...
- 配置当前用户使用豆瓣pip源
配置当前用户使用豆瓣pip源 mkdir ~/.pip/ cat ~/.pip/pip.conf [global] index-url = http://pypi.douban.com/simpl ...