The bash shell comes with two types of commands:
- Internal commands (builtins) - part of the shell itself, i.e. built into the shell.
- External commands - separate binaries stored in /sbin, /usr/sbin, /usr/bin, /bin, or /usr/local/bin directories.
Bash and Command Types
The bash shell understands the following types of commands:
- Aliases such as ll
- Keywords such as if
- Functions (user defined functions such as genpasswd)
- Built in such as pwd
- Files such as /bin/date
The type command can be used to find out a command type.
The type command can be used to find out if a command is built in or an external binary file.
Find out if ls is built in or an external command
Type the following command at a shell prompt:
type -a ls
ls is /bin/ls
To find out if history command is built in or an external command, enter:
type -a history
history is a shell built in
However, some commands are supplied as both internal and external commands. For example:
type -a true type -a echo
echo is a shell built in echo is /bin/echo
List of command bash keywords and built in commands
- JOB_SPEC &
- (( expression ))
- . filename
- [ arg... ]