Built-in commands

From Linux Bash Shell Scripting Tutorial Wiki
Jump to navigation Jump to search

Bash builtin commands (also known as "internal command") are part of the shell itself. Each builtin command is executed directly in the shell itself, instead of an external programme which the bash would load and run. For example, the top is an external command, and an alias is an internal or builtin command.

How do I find out if given command is an internal builtin or external?

Use the type command or command to find out if given command is an internal builtin or external. The syntax is:

type -a command-name-here
command -V command-name-here
## find out if top is an internal builtin or an external command ##
type -a top

Sample outputs:

top is /usr/bin/top

The bash invoke /usr/bin/top when you just type top command at shell prompt.

type -a alias

Sample outputs:

alias is a shell builtin

The bash executes the alias command directly as it is a shell builtin. Try following examples:

command -V ls
type -a ls
commamd -V date
type -a date
type -a vim
command -V vim
type -a firefox
command -V firefox

A typical output:

See also