文章目录
  1. 1. 关于Linux
    1. 1.1. Linux桌面环境介绍
    2. 1.2. Linux终端
    3. 1.3. 通配符[!list]用法:123$ touch a b c d 1 2 3 4$ ls [!ab2]$ 1 3 4 c d 通配符[c1-c2]用法: 123456$ touch a b c d 1 2 3 4$ ls [1-2]$ 1 2$ ls [1-d]1 2 3 4 a b c d 通配符{string1,string2,…}用法: 123456$ touch abc cde fgh ijk$ ls {abc,}abc$ ls {abc,cde}$ abc cde 通配符{c2..c2}用法: 1234567891011121314151617181920212223242526root@acer:~/test2# touch a b c d e f g zroot@acer:~/test2# ls {a..z}ls: cannot access h: No such file or directoryls: cannot access i: No such file or directoryls: cannot access j: No such file or directoryls: cannot access k: No such file or directoryls: cannot access l: No such file or directoryls: cannot access m: No such file or directoryls: cannot access n: No such file or directoryls: cannot access o: No such file or directoryls: cannot access p: No such file or directoryls: cannot access q: No such file or directoryls: cannot access r: No such file or directoryls: cannot access s: No such file or directoryls: cannot access t: No such file or directoryls: cannot access u: No such file or directoryls: cannot access v: No such file or directoryls: cannot access w: No such file or directoryls: cannot access x: No such file or directoryls: cannot access y: No such file or directorya b c d e f g zroot@acer:~/test2# touch loveu{1..12}monthroot@acer:~/test2# lsloveu10month loveu12month loveu2month loveu4month loveu6month loveu8monthloveu11month loveu1month loveu3month loveu5month loveu7month loveu9month
    4. 1.4. banner命令介绍

The Matrix

在线学习: 实验楼
2016-4-12周二

Linux学习路径

关于Linux

  • Linux内核是由林纳斯·托瓦兹(Linus Benedict Torvalds)在1991年10月5日首次发行
  • Linux既可以作为服务器操作系统使用,也可以作为个人计算机的独立系统使用
  • Linux内核:即Linux操作系统的核心。它的主要模块分一下几个内容:储存管理CPU和进程管理文件系统设备管理和驱动网络通信系统引导和调用

Linux桌面环境介绍

相对于现在的 Windows 系统,UNIX/Linux 本身是没有图形界面的,我们通常在 Unix/Linux 发行版上看到的图形界面实际都只是运行在 Linux 系统之上的一套软件,类似 Windows95 之前的Windows 的图形界面实则也只是运行在 DOS 环境的一套软件。而 Linux 上的这套软件以前是XFree86,现在则是 xorg(X.Org),而这套软件又是通过 X 窗口系统(X Window System,也常被称为X11或X)实现的,X 本身只是工具包及架构协议,而 xorg 便是 X 架构规范的一个实现体,也就是说它是实现了 X 协议规范的一个提供图形用户界面服务的服务器,就像实现了 http 协议提供 web 服务的 Apache。如果只有服务器也是不能实现一个完整的桌面环境的,当然还需要一个客户端,我们称为 X Client,像如下几个大家熟知也最流行的实现了客户端功能的桌面环境KDE,GNOME,XFCE,LXDE,

Linux桌面架构


Linux终端

1. Terminal(终端)
通常在我们使用 Linux 时,我们并不是直接与系统打交道,而是通过一个叫做 Shell 的中间程序来完成的,在图形界面下为了实现让我们在一个窗口中完成接受用户输入和显示输出,Linux 系统还提供了一个叫做终端模拟器的程序(Terminal),下面几个比较常见的终端模拟器,例如 gnome-terminal,kconsole,xterm,rxvt,kvt,nxterm 和 eterm,实验中的终端程序是 xfce 桌面环境自带的 xfce-terminal,不过要注意的是这里所说的终端(Terminal)和控制台(Console)是有区别的。
xfce

终端本质上是对应着 Linux 上的 /dev/tty 设备,Linux 的多用户登陆就是通过不同的 /dev/tty 设备完成的,Linux 默认提供了 6 个纯命令行界面的 “terminal”(准确的说这里应该是 6 个 virtual consoles)来让用户登录,在物理机系统上你可以通过使用[Ctrl]+[Alt]+[F1]~[F6]进行切换,不过在我们的在线实验环境中可能无法切换,因为特殊功能按键会被你主机系统劫持。当你切换到其中一个终端后想要切换回图形界面,你可以按下[Ctrl]+[Alt]+[F7]来完成。

2. Shell
通常在图形界面中对实际体验带来差异的不是上述的不同发行版的各种终端模拟器,而大都是这个 Shell(壳),有壳就有核,这里的核就是指的 UNIX/Linux 内核,Shell 是指“提供给使用者使用界面”的软件(命令解析器),类似于 DOS 下的 command(命令行)和后来的 cmd.exe。普通意义上的 Shell 就是可以接受用户输入命令的程序。它之所以被称作 Shell 是因为它隐藏了操作系统底层的细节。同样的 Unix/Linux 下的图形用户界面 GNOME 和 KDE,有时也被叫做“虚拟 shell”或“图形 shell”。

Unix/Linux 操作系统下的 Shell 既是用户交互的界面,也是控制系统的脚本语言。当然在这点也有别于 Windows 下的命令行,虽然也提供了很简单的控制语句。在Windows 操作系统下,可能有些用户从来都不会直接的使用 Shell,然而在 UNIX 系列操作系统下,Shell 仍然是控制系统启动、X11 启动和很多其他实用工具的脚本解释程序。

在 UNIX/Linux 中比较流行的常见的 Shell 有 bash,zsh,ksh,csh 等等,Ubuntu 终端默认使用的是 bash,默认的桌面环境是 GNOME 或者 Unity(基于 GNOME),但我们的环境中使用的分别是zsh 和 xfce。

Shell常用快捷键

按键 作用
ctrl + d 退出终端
ctrl + s 暂定当前程序,暂停后可按任意键恢复运行
ctrl + z 将当前程序放到后台运行,恢复到前台命令为fg
ctrl + e 将光标移至行末,相当于End
ctrl + a 将光标移动到行头,相当于Home
ctrl + k 删除从光标所在位置到行末
Alt + Backspace 向前删除一个单词
Shift + Pg Up 将终端显示向上滚动
Shift + Pg Dn 将终端向下滚动

同配符
通配符是一种特殊语句,主要有星号(*)和问号(?),用来对对字符串进行模糊匹配(比如文件名,参数名)。当查找文件夹时,可以使用它来代替一个或多个真正字符;当不知道真正字符或者懒得输入完整名字时,常常使用通配符代替一个或多个真正的字符。

终端里面输入的通配符是由 Shell 处理的,不是由所涉及到命令语句处理的,它只会出现在命令的“参数值”里(它不用在 命令名称里, 命令不记得,那就用Tab补全)。当 Shell 在“参数值”中遇到了通配符时,Shell 会将其当作路径或文件名去在磁盘上搜寻可能的匹配:若符合要求的匹配存在,则进行代换(路径扩展);否则就将该通配符作为一个普通字符传递给“命令”,然后再由命令进行处理。总之,通配符 实际上就是一种 Shell 实现的路径扩展功能。在 通配符被处理后, Shell 会先完成该命令的重组,然后再继续处理重组后的命令,直至执行该命令。

Shell常用通配符

字符 含义
* 匹配0或多个字符
? 匹配一个字符
[list] 匹配list每一个字符
[!list] 匹配list每一个字符以外的字符
[c1-c2] 匹配c1-c2中的任意字符
{string1,string2,…} 匹配string1或string2(或者更多)其中一字符串,如果只有一个字符串也要加,
{c2..c2} 匹配c1-c2中全部字符如{1..10}

实例
通配符[list]用法

1
2
3
$ touch  a  b  c  d  1  2  3  4
$ ls [abc]
$ a b c

通配符[!list]用法:
1
2
3
$ touch  a  b  c  d  1  2  3  4
$ ls [!ab2]
$ 1 3 4 c d


通配符[c1-c2]用法:
1
2
3
4
5
6
$ touch  a  b  c  d  1  2  3  4
$ ls [1-2]
$ 1 2

$ ls [1-d]
1 2 3 4 a b c d


通配符{string1,string2,…}用法:
1
2
3
4
5
6
$ touch abc  cde  fgh  ijk
$ ls {abc,}
abc

$ ls {abc,cde}
$ abc cde


通配符{c2..c2}用法:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
root@acer:~/test2# touch a b c d e f g z
root@acer:~/test2# ls {a..z}
ls: cannot access h: No such file or directory
ls: cannot access i: No such file or directory
ls: cannot access j: No such file or directory
ls: cannot access k: No such file or directory
ls: cannot access l: No such file or directory
ls: cannot access m: No such file or directory
ls: cannot access n: No such file or directory
ls: cannot access o: No such file or directory
ls: cannot access p: No such file or directory
ls: cannot access q: No such file or directory
ls: cannot access r: No such file or directory
ls: cannot access s: No such file or directory
ls: cannot access t: No such file or directory
ls: cannot access u: No such file or directory
ls: cannot access v: No such file or directory
ls: cannot access w: No such file or directory
ls: cannot access x: No such file or directory
ls: cannot access y: No such file or directory
a b c d e f g z

root@acer:~/test2# touch loveu{1..12}month
root@acer:~/test2# ls
loveu10month loveu12month loveu2month loveu4month loveu6month loveu8month
loveu11month loveu1month loveu3month loveu5month loveu7month loveu9month

帮助功能
在 Linux 环境中,如果你遇到困难,可以使用man 命令,它是Manual page的缩写。man 手册的内容很多,涉及了 Linux 使用过程中的方方面面,为了便于查找,是做了分册(分区段)处理的,在Research UNIX、BSD、OS X 和 Linux 中,手册通常被分为8个区段,安排如下:

区位 说明
1 一般命令
2 系统调用
3 库函数,涵盖了C标准函数库
4 特殊文件(通常是/dev中的设备)和驱动程序
5 文件格式和约定
6 游戏和屏保
7 杂项
8 系统管理命令和守护进程

要查看相应区段的内容,就在 man 后面加上相应区段的数字即可,如:

1
$ man 1 ls

会显示第一区段中的ls命令man页面。

所有的手册页遵循一个常见的布局,其为通过简单的 ASCII 文本展示而优化,而这种情况下可能没有任何形式的高亮或字体控制。一般包括以下部分内容:
NAME(名称)

该命令或函数的名称,接着是一行简介。

SYNOPSIS(概要)

对于命令,正式的描述它如何运行,以及需要什么样的命令行参数。对于函数,介绍函数所需的参数,以及哪个头文件包含该函数的定义。

DESCRIPTION(说明)

命令或函数功能的文本描述

EXAMPLES(示例)

常用的一些示例

也可能存在其他部分内容,但这些部分没有得到跨手册页的标准化。常见的例子包括:OPTIONS(选项),EXIT STATUS(退出状态),ENVIRONMENT(环境),BUGS(程序漏洞),FILES(文件),AUTHOR(作者),REPORTING BUGS(已知漏洞),HISTORY(历史)和COPYRIGHT(版权)。

通常 man 手册中的内容很多,你可能不太容易找到你想要的结果,不过幸运的是你可以在 man 中使用搜索,/<你要搜索的关键字>,查找到后你可以使用n键切换到下一个关键字所在处,shift+n为上一个关键字所在处。使用Space(空格键)翻页,Enter(回车键)向下滚动一行,或者使用j,k(vim编辑器的移动键)进行向前向后滚动一行。按下h键为显示使用帮助(因为man使用less作为阅读器,实为less工具的帮助),按下q退出。

想要获得更详细的帮助,你还可以使用info命令,不过通常使用man就足够了。如果你知道某个命令的作用,只是想快速查看一些它的某个具体参数的作用,那么你可以使用–help参数,大部分命令都会带有这个参数,如:

$ ls --help


banner命令介绍

1
2
3
$ sudo apt-get update;sudo apt-get install sysvbanner
$ banner take

设置字体

1
$ printerbanner -w 50 A

‘-w’参数指定打印宽度

还有两个类似的命令toilet,figlet 可通过安装来实验。

文章目录
  1. 1. 关于Linux
    1. 1.1. Linux桌面环境介绍
    2. 1.2. Linux终端
    3. 1.3. 通配符[!list]用法:123$ touch a b c d 1 2 3 4$ ls [!ab2]$ 1 3 4 c d 通配符[c1-c2]用法: 123456$ touch a b c d 1 2 3 4$ ls [1-2]$ 1 2$ ls [1-d]1 2 3 4 a b c d 通配符{string1,string2,…}用法: 123456$ touch abc cde fgh ijk$ ls {abc,}abc$ ls {abc,cde}$ abc cde 通配符{c2..c2}用法: 1234567891011121314151617181920212223242526root@acer:~/test2# touch a b c d e f g zroot@acer:~/test2# ls {a..z}ls: cannot access h: No such file or directoryls: cannot access i: No such file or directoryls: cannot access j: No such file or directoryls: cannot access k: No such file or directoryls: cannot access l: No such file or directoryls: cannot access m: No such file or directoryls: cannot access n: No such file or directoryls: cannot access o: No such file or directoryls: cannot access p: No such file or directoryls: cannot access q: No such file or directoryls: cannot access r: No such file or directoryls: cannot access s: No such file or directoryls: cannot access t: No such file or directoryls: cannot access u: No such file or directoryls: cannot access v: No such file or directoryls: cannot access w: No such file or directoryls: cannot access x: No such file or directoryls: cannot access y: No such file or directorya b c d e f g zroot@acer:~/test2# touch loveu{1..12}monthroot@acer:~/test2# lsloveu10month loveu12month loveu2month loveu4month loveu6month loveu8monthloveu11month loveu1month loveu3month loveu5month loveu7month loveu9month
    4. 1.4. banner命令介绍