天天看點

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
           

繼續閱讀