Comparison of priorities in Linux for aliases, internal commands, hash caches, and external commands (paths on the hard drive).

Source: Internet
Author: User
Tags aliases

We all know: The reading of files in the computer memory > Cache > HDD
The alias in Linux is to simplify the input of certain commands, and in the terminal input aliasCan query the system exists alias, the user can also customize the alias, specifically: Alias aliases = ' Command '

[[email protected] ~]# alias hist=‘history‘
[[email protected] ~]# hist    1  alias hist=‘history‘    2  type hsit    3  type hsitory    4  enable    5  

Use enable in Linux to get all the internal commands for Linux
Use enable-n command to disable the specified internal command in Linux
Using enable-n to display the disabled internal commands in Linux

The following is a comparison of precedence between aliases and internal commands

[[email protected] ~]# type touch    touch是外部命令touch is /bin/touch[[email protected] ~]# type cd         

You can see that aliases take precedence over internal commands
The following is the priority of the external command compared to the hash cache:
The system initial hash table is empty, if the system restarts will also be emptied, when the external command execution will go to the path to find the command, and then recorded in the hash, when the execution of the hash to take, which will speed up the execution speed. And the hash doesn't hold internal commands.

[[email protected] ~]# hash -r[[email protected] ~]# dateSat Jul 14 00:23:49 CST 2018[[email protected] ~]# hashhits    command   1    

Clears all caches in the hash, executes date, still reads from cache to date, but date has been moved to another location and cannot be executed, indicating that the hash is higher than the external path
The following is an internal command compared to the hash cache priority:
Internal commands exist directly at the memory startup and are placed directly inside the memory. Hash cache must execute the command to exist in the hash, and the hash cache inside does not put internal commands, indicating the input internal command, will not go to the hash to find, directly run. So the internal command >hash the cache.
Summary: alias > Internal command > Hash Cache > Path (external path)

Comparison of priorities in Linux for aliases, internal commands, hash caches, and external commands (paths on the hard drive).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.