Check command type using type command
In this step, you will use the type
command to get a description of how a command name is interpreted by the shell. The type
command is even more detailed than command -v
and can tell you if a command is an alias, a keyword, a function, a built-in, or a file.
Let's use type
to check the echo
command.
Type the following command in your terminal and press Enter:
type echo
You should see output similar to this:
echo is a shell builtin
This output clearly states that echo
is a shell built-in command.
Now, let's check the htop
command using type
.
Type the following command and press Enter:
type htop
The output should be similar to:
htop is /usr/bin/htop
Here, type
tells us that htop
is located at /usr/bin/htop
, indicating it's an executable file.
Let's try one more example with a command that might be an alias. Aliases are shortcuts for longer commands. While there might not be a default alias set up in this environment, let's see what type
says about a common command like ls
.
Type the following command and press Enter:
type ls
The output might vary depending on the shell configuration, but it will likely show something like:
ls is an alias for ls --color=auto
This indicates that ls
is an alias that automatically adds color to the output.
The type
command is a powerful tool for understanding how your shell resolves command names and can be very helpful for debugging scripts or understanding command behavior.