linuxbuiltin命令介绍

韵味老鸟 2024-08-22 14:02:59

linux builtin命令介绍

在Linux中,builtin命令是指那些内置于shell中的命令。这些命令的执行不需要创建新的进程,因而比外部命令执行更快

Builtin命令是指直接在shell内实现的命令,它们不依赖于外部可执行文件。执行这些命令时,shell会直接处理,而不需要通过fork创建新的子进程。这使得builtin命令在性能上更具优势,尤其是在频繁调用的情况下

常见的Builtin命令

以下是一些常见的shell builtin命令及其功能:

cd:更改当前工作目录。echo:输出文本到标准输出。exit:退出当前shell会话。export:设置或显示环境变量。alias:创建命令的别名。unset:删除变量或函数的定义。pwd:显示当前工作目录的完整路径。

一:命令介绍

root@meng:~# help cd

cd: cd [-L|[-P [-e]] [-@]] [dir]

Change the shell working directory.

Change the current directory to DIR. The default DIR is the value of the

HOME shell variable.

The variable CDPATH defines the search path for the directory containing

DIR. Alternative directory names in CDPATH are separated by a colon (:).

A null directory name is the same as the current directory. If DIR begins

with a slash (/), then CDPATH is not used.

If the directory is not found, and the shell option `cdable_vars' is set,

the word is assumed to be a variable name. If that variable has a value,

its value is used for DIR.

Options:

-L force symbolic links to be followed: resolve symbolic

links in DIR after processing instances of `..'

-P use the physical directory structure without following

symbolic links: resolve symbolic links in DIR before

processing instances of `..'

-e if the -P option is supplied, and the current working

directory cannot be determined successfully, exit with

a non-zero status

-@ on systems that support it, present a file with extended

attributes as a directory containing the file attributes

The default is to follow symbolic links, as if `-L' were specified.

`..' is processed by removing the immediately previous pathname component

back to a slash or the beginning of DIR.

Exit Status:

Returns 0 if the directory is changed, and if $PWD is set successfully when

-P is used; non-zero otherwise.

root@meng:~# help ls

-bash: help: no help topics match `ls'. Try `help help' or `man -k ls' or `info ls'.

root@meng:~# alias ls

alias ls='ls --color=auto'

root@meng:~# help pwd

pwd: pwd [-LP]

Print the name of the current working directory.

Options:

-L print the value of $PWD if it names the current working

directory

-P print the physical directory, without any symbolic links

By default, `pwd' behaves as if `-L' were specified.

Exit Status:

Returns 0 unless an invalid option is given or the current directory

cannot be read.

root@meng:~# type -t ls

alias

root@meng:~# type -t cd

builtin

root@meng:~# type -t pwd

builtin

root@meng:~#

0 阅读:4

韵味老鸟

简介:感谢大家的关注