type

type is a utility that shows you how its arguments would be interpreted if run as a command. There are four "types" of Unix utilities, and the type command displays the passed utilities type.

The four "types" of Unix utilities are:

  • Executables

  • Shell built-ins

  • Shell functions

  • Aliases

Here is how the type command is used:

type ls

When you run this on your local machine, you might see something like this:

Output
ls is /bin/ls

This means that the ls command is an executable. Most likely, you will not be using this command each and every day. But like which, it may come in handy down the road, and is a great tool to have in your toolbox.

One example where type may come in handy is when trying to figure out where the module command is located on Scholar. You may be thinking, we can use which for this, but it will not have the information you want.

which module
Output
/usr/bin/which: no module in (...)

The reason is that module is a shell built-in, and which is a utility that shows you where the command is located, not where a function is located. type, however, can help you out.

type -f module
Output
module () {
	eval $($LMOD_CMD bash "[email protected]") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)
}

Resources

A succinct description of the type command can be found here.