天天看点

Linux命令类型和执行顺序-type命令

type命令:

用来显示指定命令的类型,判断给出的指令是内部指令还是外部指令。

type查看的Linux中的命令类型:

  1. alias:别名。
  2. keyword:关键字,Shell保留字。
  3. function:函数,Shell函数。
  4. builtin:内建命令,Shell内建命令。
  5. file:文件,磁盘文件,外部命令。
  6. unfound:没有找到。

type命令选项

-t:直接显示命令类型

-p:如果给出的指令为外部指令,则显示其绝对路径;

-a:显示命令执行顺序

配置举例:

1、显示指定的命令类型

[[email protected] ~]# type cd
cd is a shell builtin
[[email protected] ~]# type ls
ls is aliased to `ls --color=auto'
[[email protected] ~]# type mount
mount is /usr/bin/mount
           

2、直接显示命令类型

[[email protected] ~]# type -t cd
builtin
[[email protected] ~]# type -t ls
alias
[[email protected] ~]# type -t mount
file
           

3、显示命令执行顺序

[[email protected] ~]# type -a cd
cd is a shell builtin
cd is /usr/bin/cd
[[email protected] ~]# type -a ls
ls is aliased to `ls --color=auto'
ls is /usr/bin/ls
[[email protected] ~]# type -a mount
mount is /usr/bin/mount
           

继续阅读