概念
什么叫做内置命令,什么叫做外置命令?
内置命令:在系统启动时就加载入内存,常驻内存,执行效率更高,但是占用资源,cd
外置命令:系统需要从硬盘中读取程序文件,再读入内存加载
例如:
xiao123@xiao123:~/Downloads/shscripts$ type cd #bash 内置命令
cd is a shell builtin
xiao123@xiao123:~/Downloads/shscripts$ type awk #bash 外置命令
awk is /usr/bin/awk
xiao123@xiao123:~/Downloads/shscripts$
区别
外置命令
一定会开启子进程执行。
内置命令
不会开启子进程去执行。
内置命令
与shell是一体的,不需要单独去读取某个文件,系统启动后,就执行在内存中了。
验证是否是内置命令
type
:检查Linux内置命令。
查看Linux内置shell命令
comgen -b
:查看Linux当前的shell内置命令。
xiao123@xiao123:~/Downloads/shscripts$ compgen -b
.
:
[
alias
bg
bind
break
builtin
caller
cd
command
compgen
complete
compopt
continue
declare
dirs
disown
echo
enable
eval
exec
exit
export
false
fc
fg
getopts
hash
help
history
jobs
kill
let
local
logout
mapfile
popd
printf
pushd
pwd
read
readarray
readonly
return
set
shift
shopt
source
suspend
test
times
trap
true
type
typeset
ulimit
umask
unalias
unset
wait
xiao123@xiao123:~/Downloads/shscripts$