在shell中可执行命令分为:
  内部命令:由shell自带,会随着系统启动

  外部命令:在系统中有对应的可执行文件

命令执行:
    输入命令后回车,提请shell程序找到键入命令所对应的可执行程序   或代码,并由其分
    析后提交给    内核分配资源将其运行起来

hash表 
    系统初始hash表为空,当外部命令执行时,默认会从PATH路径下寻找该命令,找到后会将  
    这条命令的路径记录到hash表中,当再次使用该命令时,shell解释器首先会查看hash表,  
    存在将执行之,如果不存在,将会去PATH路径下寻找,
    利用hash缓存表可大大提高命令的调用速率   
        hash常见用法
    hash 显示hash缓存
    hash –l 显示hash缓存,可作为输入使用
    hash –p path name 将命令全路径path起别名为name
    hash –t name 打印缓存中name的路径
    hash –d name 清除name缓存
    hash –r 清除缓存

内部命令直接从内存中读取,通过type可查看命令是否为内部命令

[root@centos1 ~]#type pwd   # 内部命令
pwd is a shell builtin
[root@centos1 ~]#type top   # 外部命令
top is /usr/bin/top
[root@centos1 ~]#help    #查看所有内部命令

外部命令需要从系统文件中读取

[root@centos1 ~]#echo $PATH  # 查看外部命令搜索路径
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin  
[root@centos1 ~]#which top # 查看外部命令可执行文件的路径
/usr/bin/top
[root@centos1 ~]#whereis top # 查看外部命令可执行文件的路径以及帮助文档路径
top: /usr/bin/top /usr/share/man/man1/top.1.gz  
[root@centos1 ~]#hash # 为了加快外部命令的执行过程会放入缓存表
hits    command
   1    /usr/bin/cal
   3    /usr/bin/tail
   2    /usr/bin/timedatectl
  15    /usr/bin/date
   1    /usr/bin/cat
   5    /usr/bin/whereis
   2    /usr/bin/ls

[root@centos1 ~]#type
[root@centos1 ~]#type pwd
pwd is a shell builtin
[root@centos1 ~]#alias pwd='ls /data'  #当有别名时优先执行别名
[root@centos1 ~]#pwd  
backup2019-05-16  f1  f2  win1.txt  win2.txt  zz.txt

命令执行优先级:别名>内部命令>hash表中的命令>外部命令