外部命令位于磁盘上,使用时需要加载到内存中,常见命令有 vi 、ls 等。
Bash Shell 内置命令是一个命令或函数,从 shell 中调用,它直接在 shell 中执行。 bash shell 直接执行该命令而无需调用其他程序。运行在内存中,加载速度很快。
内置命令列表使用 help 命令查看。
#使用方法1
[root@promote ~]# help
#可以上下移动鼠标查看帮助
[root@promote ~]# help | less
#查看read帮助
[root@promote ~]# help | grep read
#使用方法2 查看简洁帮助列表
[root@promote ~]# compgen -b
[root@promote ~]# 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
[root@promote ~]#
具体内置命令查看方法如下。
#举例说明,未列举全部
[root@promote ~]# help cd
[root@promote ~]# help :
[root@promote ~]# help true
true: 真
返回一个成功结果。
退出状态:
总是成功
[root@promote ~]#
通过 type 或 command 命令可以区分内置还是外部命令。
[root@promote ~]# type cd
cd 是 shell 内嵌
[root@promote ~]# type -a : . [
: 是 shell 内嵌
. 是 shell 内嵌
[ 是 shell 内嵌
[ 是 /usr/bin/[
[root@promote ~]# command -V ls
ls 是 `ls --color=auto' 的别名
[root@promote ~]# command -V cd
cd 是 shell 内嵌
[root@promote ~]#