Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Built-in and external commands in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "built-in commands and external commands in Linux". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "built-in commands and external commands in Linux".

Linux commands are divided into internal commands and external commands:

1. Internal commands are called into memory when the system is started, and are resident in memory, so the execution efficiency is high.

two。 The external command is the software function of the system, and the user only reads the memory from the hard disk when needed.

Type can be used to determine whether a command is a built-in command

The code is as follows:

Type: usage: type [- afptP] name [name...]

The code is as follows:

[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 can not only view internal commands, but also determine whether they are internal commands.

The code is as follows:

[root@linuxeye ~] # enable-a # View internal commands

[root@linuxeye ~] # enable whiptail # non-internal command

-bash: enable: whiptail: not a shell builtin

[root@linuxeye ~] # enable pwd # is an internal command

Internal command user input when the system call rate is fast, not built-in commands, the system will read the environment variable file .bash _ profile, / etc/profile to find the PATH path.

Then when you mention the invocation of the command, some historical commands will exist in the hash table after they have been used, and the call to the command will be such a process when you type the command again.

The invocation of the hash-- > built-in command-- > PATH command should actually be such a process.

The code is as follows:

[root@linuxeye ~] # type pwd

Pwd is a shell builtin

[root@linuxeye ~] # type cat

Cat is / usr/bin/cat

[root@linuxeye ~] # pwd

/ root

[root@linuxeye ~] # ls linuxeye*

Linuxeye.pem linuxeye.txt

[root@linuxeye ~] # cat linuxeye.txt

Linuxeye

[root@linuxeye ~] # hash-l # displays the hash table

Builtin hash-p / usr/bin/cat cat

Builtin hash-p / usr/bin/ls ls

[root@linuxeye ~] # type cat

Cat is hashed (/ usr/bin/cat)

[root@linuxeye ~] # hash-r # clear the hash table

[root@linuxeye ~] # type cat

Cat is / usr/bin/cat

As can be seen from the above operation. The hash table does not hold system built-in commands.

At this point, I believe you have a deeper understanding of the "built-in commands and external commands in Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report