Shell commands
From Linux Shell Scripting Tutorial - A Beginner's handbook
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.
Contents |
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.
type command
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
Sample Output:
ls is /bin/ls
To find out if history command is built in or an external command, enter:
type -a history
sample Output:
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
sample Outputs:
echo is a shell built in echo is /bin/echo
List of command bash keywords and built in commands
- JOB_SPEC &
- (( expression ))
- . filename
- [[:]]
- [ arg... ]
- expression
- alias
- bg
- bind
- builtin
- caller
- case
- command
- compgen
- complete
- continue
- declare
- dirs
- disown
- echo
- enable
- eval
- exec
- exit
- export
- false
- fc
- fg
- for
- getopts
- hash
- help
- history
- if
- jobs
- kill
- let
- local
- logout
- popd
- printf
- pushd
- pwd
- read
- readonly
- return
- select
- set
- shift
- shopt
- source
- suspend
- test
- time
- times
- trap
- true
- type
- typeset
- ulimit
- umask
- unalias
- unset
- until
- variables
- while