# Shell builtin

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Shell_builtin
> Markdown URL: https://mediated.wiki/source/Shell_builtin.md
> Source: https://en.wikipedia.org/wiki/Shell_builtin
> Source revision: 1336335512
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Computer function}}
In computing, a '''shell builtin''' is a [command](/source/Command_(computing)) or a [function](/source/Subroutine), exposed by a [shell](/source/Shell_(computing)), that is implemented in the shell itself, instead of an external [program](/source/computer_program) which the shell would load and execute.<ref>{{Cite web |url=http://pubs.opengroup.org/onlinepubs/9699919799//utilities/V3_chap02.html#tag_18_09 |title=POSIX standard: Shell Commands |access-date=2016-11-01 |archive-date=2016-10-29 |archive-url=https://web.archive.org/web/20161029143247/http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09 |url-status=live }}</ref><ref>{{cite book |last1=Tansley |first1=David |title=Linux and Unix shell programming |date=2000 |publisher=Addison-Wesley |location=Harlow |isbn=9780201674729 |chapter=24. Shell built-in commands}}</ref><ref>{{cite book |last1=Sobell |first1=Mark G. |title=A Practical Guide to Red Hat Linux 8 |date=2003 |pages=161–162 |chapter-url=https://books.google.com/books?id=7ExfDfcLZXsC&dq=shell+built-in+commands&pg=PA162 |chapter=Built-ins}}</ref><ref>{{cite book |author1=Albing, Carl |author2=Vossen, JP |author3=Newham, Cameron |title=Bash Cookbook |publisher=O'Reilly Media |isbn=9780596554705 |pages=13–15 |chapter-url=https://books.google.com/books?id=Qu6H8fnAvGoC&dq=shell+built-in+commands&pg=PA14 |chapter=1.7. Using or Replacing Built-ins and External Commands}}</ref>

A shell builtin starts faster than an external program because there is no program loading overhead. However, its implementation code is in the shell program, and thus modifying it requires modifying the shell. Therefore, a shell builtin is usually only used for simple, almost trivial, commands, such as text output.

Some commands must be implemented as builtins due to the nature of the [operating system](/source/operating_system). 
Notably, the <code>[cd](/source/cd_(command))</code> command, which changes the [working directory](/source/working_directory) of the shell is often a builtin since a program runs in a separate [process](/source/Process_(computing)) and working directory is specific to each process. Running <code>cd</code> as an external program would not affect the working directory of the shell that loaded it.<ref>{{cite book |last1=Kuhn |first1=Darl |last2=Kim |first2=Charles |last3=Lopuz |first3=Bernard |title=Linux and Solaris Recipes for Oracle DBAs |date=2015 |publisher=Apress |location=Berkeley, CA |isbn=9781484212547 |pages=47 |edition=2nd |url=https://books.google.com/books?id=p-wLCwAAQBAJ&dq=shell+built-in+commands&pg=PA46}}</ref>

==See also==
* {{Annotated link |BusyBox}}
* {{Annotated link |List of DOS commands}}
* {{Annotated link |List of POSIX commands}}

==References==
{{Reflist}}

==External links==
* [http://pubs.opengroup.org/onlinepubs/9699919799//utilities/V3_chap02.html#tag_18_14 List of special shell builtin commands]
* [http://www.computerhope.com/jargon/i/intecomm.htm List of MS-DOS internal commands]

{{Unix commands}}
{{Windows commands}}

{{DEFAULTSORT:Shell Builtin}}
Category:Command shells

{{Operating-system-stub}}

---
Adapted from the Wikipedia article [Shell builtin](https://en.wikipedia.org/wiki/Shell_builtin) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Shell_builtin?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
