Linux 内建命令 VS 外键命令
Linux 内建命令 VS 外键命令
对比:
项目 | 内建命令 | 外键命令 |
---|---|---|
概念 | shell的一部分(由shell识别并执行) | 命令实体通常不包含在shell中(执行由shell执行) |
加载 | 随系统加载 | 不随系统加载(需要时候加载到内存) |
帮助查看方法【补充(2)】 | help 命令 | 命令 --help |
执行【补充(3)】 | 不会产生新的进程 | 会产生命令对应的进程 |
补充:
(1)查看内部命令还是外部命令,使用内建的type command
[root@localhost tmp]# type pwd
pwd is a shell builtin (--builtin是内建命令--)
[root@localhost tmp]# type vi
vi is /usr/bin/vi (--外部命令,显示了外部命令所在的位置--)
(2)查看命令的帮助:
help 内建命令: 启动的是help命令(也是一个内建命令),传入要查看的命令名称
外部命令 --help:启动的是外部命令,传入参数help,得到该命令的参考信息
[root@localhost tmp]# help pwd (--启动help命令,查看内建命令的帮助信息--)
pwd: pwd [-LP]
Print the name of the current working directory.
Options:
-L print the value of $PWD if it names the current working (略)
[root@localhost tmp]# vi --help (--启动外部vi命令,查看其帮助信息--)
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 10 2018 23:54:54)
usage: vim [arguments] [file ..] edit specified file(s)
or: vim [arguments] - read text from stdin
or: vim [arguments] -t tag edit file where tag is defined
Arguments: (略)
(3)执行命令时候的进程:
外部命令以vi为例:
执行 vi /tmp/1.sh前后的进程情况,执行vi后,出现了vi的进程
[root@localhost ~]# ps -ef|grep vi (--执行vi命令前--)
root 12129 12102 0 17:33 pts/1 00:00:00 grep --color=auto vi
另一个shell窗口查看
[root@localhost ~]# ps -ef|grep vi (--使用另外一个窗口,执行vi命令后--)
root 12130 1692 0 17:33 pts/0 00:00:00 vi 1.sh (--vi的进程--)
root 12132 12102 0 17:33 pts/1 00:00:00 grep --color=auto vi