Linux下内置命令和外部命令详解
作者
Linux的命令分为内部命令和外部命令:
- 内部命令在系统启动时就调入内存,是常驻内存的,所以执行效率高。
- 外部命令是系统的软件功能,用户需要时才从硬盘中读入内存。
type可以用来判断一个命令是否为内置命令
- type: usage: type [-afptP] name [name ...]
- [root@linuxeye ~]# type type
- type is a shell builtin
- [root@linuxeye ~]# type -p type
- [root@linuxeye ~]# type -t type
- builtin
- [root@linuxeye ~]# type type
- type is a shell builtin
- [root@linuxeye ~]# type -t type
- builtin
- [root@linuxeye ~]# type pwd
- pwd is a shell builtin
- [root@linuxeye ~]# type whiptail
- whiptail is /usr/bin/whiptail
- [root@linuxeye ~]# type -t whiptail
- file
enable既可以查看内部命令,同时也可以判断是否为内部命令
- [root@linuxeye ~]# enable -a #查看内部命令
- [root@linuxeye ~]# enable whiptail #非内部命令
- -bash: enable: whiptail: not a shell builtin
- [root@linuxeye ~]# enable pwd #是内部命令
内部命令用户输入时系统调用的速率快,不是内置命令,系统将会读取环境变量文件.bash_profile、/etc/profile去找PATH路径。
然后在提一下命令的调用,有些历史命令使用过后,会存在在hash表中,当你再次输入该命令它的调用会是这样一个过程。
hash——>内置命令——>PATH 命令的调用其实应该是这样一个过程。
- [root@linuxeye~]#typepwd
- pwdisashellbuiltin
- [root@linuxeye~]#typecat
- catis/usr/bin/cat
- [root@linuxeye~]#pwd
- /root
- [root@linuxeye~]#lslinuxeye*
- linuxeye.pemlinuxeye.txt
- [root@linuxeye~]#catlinuxeye.txt
- linuxeye
- [root@linuxeye~]#hash-l#显示hash表
- builtinhash-p/usr/bin/catcat
- builtinhash-p/usr/bin/lsls
- [root@linuxeye~]#typecat
- catishashed(/usr/bin/cat)
- [root@linuxeye~]#hash-r#清除hash表
- [root@linuxeye~]#typecat
- catis/usr/bin/cat
从上面操作可以看出。hash表不存放系统内置命令。
Wed May 13 12:03:53 CST 2015目录
推荐阅读
-
Linux关于透明大页机制的介绍
-
Unix/Linux中最常用的50个命令
1.tar创建一个新的tar文件$tarcvfarchive_name.tardirname/解压tar文件$...
-
Linux安装Docker详细教程
目录介绍安装条件卸载旧版本安装方法常用命令卸载dockerCompose编排安装卸载dockercompose介绍Docke...
-
Linux环境下安装python3
1.python下载请在终端输入如下命令:cd/homewgethttp://cdn.npm.taobao.org/di...
-
Linux实现项目的自动化部署
一、自动化部署git项目#!/bin/bash#清除项目进程和历史文件pkill-fstart.pysleep...
-
Linux中各个目录的作用与内容
-
Linux常用高频命令
-
Linux中sftp常用命令整理
SFTP的概念sftp是SecureFileTransferProtocol的缩写,安全文件传送协议。可以为传输文件提供一...
-
Linux中文件的基本属性介绍
-
Linux文件系统介绍