Linux命令执行优先级

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

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

通过type可查看命令是否为内部命令

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

内部命令直接从内存中读取而外部命令需要从系统文件中读取

[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表中的命令>外部命令

转载于:https://blog.51cto.com/14322729/2392937

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值