Linux基础编程

    xiaoxiao2025-09-02  2

    文章目录

    课时3_shell操作的快捷键1、shell介绍2、Tab键作用3、遍历历史命令记录4、删除5、移动

    课时3_shell操作的快捷键

    1、shell介绍

    shell–unix–Bourne shell

    bash–linux–Bourne again shell

    shell可以理解为一个后台运行的应用程序,是一个命令解析器

    命令解析器的作用(shell工作原理):

    1.解析用户输入的命令;

    2.搜索环境变量:路径;

    3.找到了输入的命令,运行这个程序;

    4.终端下有对应的输出;

    2、Tab键作用

    1、命令或目录补齐

    2、目录或文件名称记忆不完整时连按两下tab键:显示文件/目录列表

    3、遍历历史命令记录

    history命令:显示历史命令列表

    上一条命令:ctrl+p 或者 向上方向键

    下一条命令:ctrl+n 或者 向下方向键

    知识拓展:快速执行历史命令:!+历史命令序号

    例如下面例子中,先用history命令查看历史命令,每一行的第一列是历史命令的序号,则使用!45可以快速执行ll命令。

    39 ls 40 cd /home 41 cd .. 42 cd /usr/ 43 cd /usr/lib/ 44 cd /usr/local/ 45 ll 46 history root@prs:/usr/local# !45 ll 总用量 40 drwxr-xr-x 10 root root 4096 3月 5 07:32 ./ drwxr-xr-x 10 root root 4096 3月 5 07:32 ../ drwxr-xr-x 2 root root 4096 3月 5 07:32 bin/ drwxr-xr-x 2 root root 4096 3月 5 07:32 etc/ drwxr-xr-x 2 root root 4096 3月 5 07:32 games/ drwxr-xr-x 2 root root 4096 3月 5 07:32 include/ drwxr-xr-x 4 root root 4096 3月 5 07:36 lib/ lrwxrwxrwx 1 root root 9 5月 26 12:00 man -> share/man/ drwxr-xr-x 2 root root 4096 3月 5 07:32 sbin/ drwxr-xr-x 7 root root 4096 3月 5 07:37 share/ drwxr-xr-x 2 root root 4096 3月 5 07:32 src/

    4、删除

    删除光标前边字符:backspace 或者 ctrl+h

    删除光标后边字符:ctrl+d

    删除光标前边字符串:ctrl+u

    删除光标后边字符串:ctrl+k

    5、移动

    向前:ctrl+b 或者 向左方向键

    向后:ctrl+f 或者 向右方向键

    移动到头部:ctrl+a

    最新回复(0)