码迷,mamicode.com
首页 > 系统相关 > 详细

Linux命令执行过程

时间:2019-05-12 10:48:53      阅读:313      评论:0      收藏:0      [点我收藏+]

标签:pwd   系统文件   EDA   hash   hits   执行   直接   外部   查看   

在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

命令执行顺序:内部命令>hash表中的命令>外部命令

Linux命令执行过程

标签:pwd   系统文件   EDA   hash   hits   执行   直接   外部   查看   

原文地址:https://blog.51cto.com/14322729/2392937

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!