374 words
1 minute
shell程序
1. shell
1.1 概念
- shell 程序是一种交互式程序,区别于 shell 脚本。
1.2 shell 的类型
- 启动时涉及两种 shell:
- 默认的交互 shell
- 用户登录后启动的 shell 程序由
/etc/passwd中用户记录的最后一个字段指定。
- 用户登录后启动的 shell 程序由
- 默认的系统 shell
- 启动时运行 shell 脚本使用,通常是
/bin/sh,作为符号链接指向启动 shell。
- 启动时运行 shell 脚本使用,通常是
- 默认的交互 shell
2. shell 的父子关系
2.1 父子 shell
- 父子 shell 都是相对的:
- 父 shell:起始启动的交互式 shell 是一个父 shell。
- 子 shell:在一个 shell 中输入
bash命令时,会创建一个新的 shell 程序,被称为子 shell。
- 使用
exit命令退出子 shell。
2.2 进程列表
- 在一行中指定要依次运行的一系列命令,用
;隔开:$ pwd ; ls ; cd /etc ; pwd ; cd ; pwd ; ls - 在命令列表外加上
(),才形成进程列表,生成一个子 shell 来执行命令:$ (pwd ; ls ; cd /etc ; pwd ; cd ; pwd ; ls)
3. 内建命令、外部命令
3.1 内建命令
- 内建命令是 shell 程序自身实现的命令,不需要借助外部程序文件来运行,不会创建子进程。
- 内建命令的执行速度要更快,效率也更高。
- 使用
type命令了解某个命令是否为内建:$ type cdcd is a shell builtin
3.2 外部命令
- 外部命令是存在于 bash shell 之外的程序,不是 shell 的一部分。
- 执行外部命令时,会创建出一个子进程。
Share
If this article helped you, please share it with others!
shell程序
https://kieas.cn/posts/shell程序/ Some information may be outdated
Related Posts Smart
1
Linux环境变量
Linux Linux 环境变量的概念、全局与局部变量、用户自定义变量、PATH 设置,以及登录、交互式和非交互式 shell 启动文件的整理笔记。
2
Linux文件权限
Linux Linux 用户与用户组、账户文件、文件权限,以及 useradd、usermod、groupadd、chmod、chown 等常用操作命令的整理笔记。
3
函数与函数式编程
Python Python 函数的定义与调用、形参与实参、作用域,以及 lambda 匿名函数的整理笔记。
4
模块与模块化编程
Python Python 模块的导入方式、模块别名与单独运行,以及包的定义、包索引和相对导入的整理笔记。
5
L1.HTML语法
Web 用于测试。