Linux命令到底是什么?

在Linux上,我们都使用过一些linux命令吧,但是,你知道Linux命令到底是什么,它分为哪几类吗?

Linux中命令是如下4中类型中的一种。
1.在$PATH中可执行程序;
2.shell自身的内部命令,即shell builtin;
3.一个shell函数(可以将脚本source而得到其中函数);
4.一个别名(其他命令的别名,用alias命令来定义)。

What Exactly Are Commands?
A command can be one of four different things:
1. An executable program like all those files we saw in /usr/bin. Within this category, programs can be compiled binaries such as programs written in C and C++, or programs written in scripting languages such as the shell, perl, python, ruby, etc.
2. A command built into the shell itself. Bash supports a number of commands internally called shell builtins. The cd command, for example, is a shell builtin.
3. A shell function. These are miniature shell scripts incorporated into the environment. We will cover configuring the environment and writing shell functions in later chapters, but for now, just be aware that they exist.
4. An alias. Commands that we can define by ourselves, be built from other commands.

可以使用type命令来查看一个命令的类型。
下面是一些例子吧:

执行命令前,shell按照以下顺序判定程序类型:
1、别名
2、关键字。
3、函数(bash)
4、内置命令
5、可执行程序

master

Stay hungry, stay foolish.

发表评论

电子邮件地址不会被公开。 必填项已用*标注