Shell commands

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← The bash shellHomeThe role of shells in the Linux environment →

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.

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

← The bash shellHomeThe role of shells in the Linux environment →