走进shell

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了走进shell相关的知识,希望对你有一定的参考价值。

几个术语

哑终端(dumb terminal):

A dumb terminal was usually nothing more than

a monitor and keyboard connected to the Unix system via a communication cable (usually a multiwire
serial cable多线串行电缆,也叫带状电缆). This simple combination provided an easy way to enter text data into the Unix
system and view text results.

控制台终端、图形终端

控制台终端:

When the Linux system starts, it automatically creates several virtual consoles. A virtual
console is a terminal session that runs in Linux system memory. Instead of having several
dumb terminals connected to the computer, most Linux distributions start fi ve or six (or
sometimes even more) virtual consoles that you can access from a single computer keyboard
and monitor.

图形终端:

使用图形化Linux桌面环境(Linux graphical desktop environment)的终端模拟包(terminal emulation package),终端模拟包会模拟在哑终端上工作,所有的都在桌面上的一个图形化窗口中。

图形终端只(Graphical terminal emulation)只是Linux图形显示的一小部分。作为一个整体,Linux图形显示有几部分组成

技术分享

图形终端模拟软件(graphical terminal emulation software)也叫client

二者区别与联系

  尽管在启动Linux系统的时候有几个虚拟终端(virtual consoles)被创建,但是许多Linux发行版本在Linux启动序列完成后会切换到图形环境,从而登录系统都是通过图形界面的方式。因此,访问虚拟终端(virtual consoles)只能通过手工方式。

  在大多数Linux发行版本中,你可以使用快捷键(Ctrl+Alt F1~F7)来切换不同的终端。文本模式的虚拟终端会以全屏显示,类似下图

技术分享

tty2说明:

tty:teletypewriter,很老的设备,用来发送消息

2:  表明你在使用第二个虚拟终端,即你是要Ctrl+Alt+F2切换来的

值得注意的一点是,你可以在数个虚拟终端之间来回切换而不用担心工作丢失。但是在Linux虚拟终端中,你是不能运行任何图形程序的。这就比较蛋疼了,如果我想要运行图形程序怎么办呢?

使用Linux桌面环境下的图形终端

在Linux图形桌面环境下有许多可用的终端模拟包(terminal emulation package),相对于传统的虚拟终端而言(virtual consoles),这些终端模拟包会提供一组特性帮助用户使用。常见终端模拟包(terminal emulation package)见下表

技术分享

尽管有这么多terminal emulation package可以使用,但主要的还是GNOME Terminal, Konsole Terminal以及 xterm。在许多Linux发行版中这三个都是作为默认的图形终端。

 GNOME Terminal Emulator

注意区分如下概念:

图形终端             :上面表格里面那几种

Linux桌面环境     :GNOME desktop、Ubuntu Unity

Linux发行版本     :RHEL、Fedora、CentOS

GNOME terminal emulator作为GNOME desktop的默认图形终端。由于RHEL、Fedora、CentOS这几个Linux发行版本使用GNOME desktop作为自己的图形桌面环境,所以GNOME terminal emulator也就成了RHEL、Fedora、CentOS的默认图形终端。值得注意的一点是,Ubuntu Unity桌面环境也是用GNOME terminal emulator作为自己的图形终端。

Konsole Terminal Emulator

The KDE Desktop Project created its own terminal emulation package called Konsole
Terminal. The Konsole package incorporates basic terminal emulation features, along with
more advanced ones expected from a graphical application.

xterm Terminal Emulator

The oldest and most basic of terminal emulation packages is xterm. The xterm package has
been around since before the original days of X Window, a popular display server, and it’s
often included by default in distributions.
Although xterm is a full terminal emulation package, it doesn’t require many resources
(such as memory) to operate. Because of this, the xterm package is still popular in Linux
distributions designed to run on older hardware. Some graphical desktop environments use
it as the default terminal emulation package.
Although it doesn’t offer many fancy features, the xterm package does one thing extremely
well: It emulates older terminals, such as the Digital Equipment Corporation (DEC) VT102,
VT220, and Tektronix 4014 terminals. For the VT102 and VT220 terminals, xterm can even
emulate the VT series of color control codes, allowing you to use color in your scripts.

灵活设置虚拟终端的显示效果

技术分享

以上是关于走进shell的主要内容,如果未能解决你的问题,请参考以下文章

走进shell

终端控制台虚拟终端伪终端的概念,阐述终端与shell的关系

终端、控制台、tty、shell等区别与概念初辨析

如何在 Unix 控制台或 Mac 终端上运行 shell 脚本?

控制台,终端,tty,shell等概念的区别

Shell终端光标和颜色控制