bash 內部命令

來源:互聯網
上載者:User

在調試板子的時候,發現在PATH對應的路徑中沒有alias這個命令,但是居然可以用,

 

查閱資料後,終於明白shell是如何執行命令解釋了。

 

首先shell判斷使用者輸入的命令是否是內部命令

 

*是內部命令,直接執行

*不是內部命令,在PATH對應的目錄中搜尋對應的單獨的程式,存在執行,不存在報錯

 

linux的命令可以分為內部命令和外部命令。

內部命令在系統啟動時就調入記憶體,是常駐記憶體的,所以執行效率高。

而外部命令是系統的軟體功能,使用者需要時才從硬碟中讀入記憶體。

 

在終端下輸入man builtins,即可調出內部命令的大綱和解釋

[root@localhost bin]# man builtins
BASH_BUILTINS(1)                                                                                                          BASH_BUILTINS(1)

NAME
       bash,  :,  .,  [,  alias,  bg, bind, break, builtin, cd, command, compgen, complete, continue, declare, dirs, disown, echo, enable,
       eval, exec, exit, export, fc, fg, getopts, hash, help, history, jobs, kill, let, local, logout, popd,  printf,  pushd,  pwd,  read,
       readonly,  return, set, shift, shopt, source, suspend, test, times, trap, type, typeset, ulimit, umask, unalias, unset, wait - bash
       built-in commands, see bash(1)

 

或者使用enable命令,分行列出內部命令

[root@localhost bin]# enable
enable .
enable :
enable [
enable alias
enable bg
enable bind
enable break
enable builtin
enable caller
enable cd
enable command
enable compgen
enable complete

 

如果想查一下一個命令是內部的還是外部的,可以這樣:

[root@localhost bin]# enable ls
-bash: enable: ls: not a shell builtin

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.