checking command type

created onJanuary 18, 2022

types of shell commands

There are four types of shell commands:

  • shell builtin – commands, that are built into the shell. and are more often than not shell builtins. Note, that a command can be available as a shell builtin and as an executable or shell script (see next type). An example on my system is the command .
  • compiled executable / shell script – compiled and installed programs. I.e., programs in and compiled programs installed in or somewhere in.
    Scripts, that are executed in a shell or an interpreter like Perl, which is available in most Linux systems in .
  • shell alias – aliases for commands that are defined in .
  • shell function – shell functions that are sourced (read) in .

checking command type with type

To check the type of a command, run , i.e. . The following section lists the output of for the four types of shell commands listed above.

shell builtin

general form

<command> is a shell builtin

example

rudolf@idoru:~$ type test test is a shell builtin rudolf@idoru:~$

compiled executable / shell script

general form

<command> is <path to command executable>

example

rudolf@idoru:~$ type ssh ssh is /usr/bin/ssh rudolf@idoru:~$

shell alias

general form

<command> is aliased to <alias definition in .bashrc>

example

rudolf@idoru:~$ type ls ls is aliased to `ls --color=auto' rudolf@idoru:~$

shell function

general form

<command> is a function

example

rudolf@idoru:~$ type javaversion javaversion is a function javaversion () { javaDir=/opt/sys/vm; versions=/opt/sys/vm/vm-versions; . ${versions}; ## rest of function omitted here for brevity return ${errcode} } rudolf@idoru:~$