Shell builtin

From LQWiki
(Redirected from BuiltIn)
Jump to: navigation, search

A shell builtin (usually just builtin) is a command available through a shell, rather than being an independent executable file. Builtins include such things as cd and echo and much of the apparatus of job control and so on. They also include "help" which will display a list of builtins and can be used as help builtin for further information on that builtin.

Some builtins have the same name as independent files, such as the aforementioned "echo". The file can be accessed by providing the full path or by using the "enable" builtin to disable the builtin.

Knowing whether a command is a builtin

To know whether a command is a built-in or not, you can use the "type" command. If the command is a builtin, <command-name> is a shell builtin will be displayed:

tweedleburg:~ # echo $SHELL
tweedleburg:~ # type ls
ls is aliased to `ls $LS_OPTIONS'
tweedleburg:~ # type cp
cp is /bin/cp
tweedleburg:~ # type wait
wait is a shell builtin