Beginners Guide for Type Command in Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

The type command tells you the actual type of the referenced command. With this information, you can figure out how a command will be interpreted when you execute it in the terminal.

The following is the list of known command types:

  • Alias
  • Shell built-in
  • File
  • Function
  • Keyword

Aside from showing the file type, this command can also be used to find and show all the locations that contain the referenced command (in binary).

Knowing all the things it offers might discourage your desire to go forward, but trust me, this command will come in handy, especially when you’re trying to figure out why a command is acting in a certain way.

So, read this article to find out everything you need to know about this command, including its different options (with practical examples).

Tutorial Details

Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Internet RequiredNo

Syntax of the Type Command

The type command takes two arguments: one is the option, and the other is the command or file name.


Identifying the Actual Type of the Referenced Command

To make things easier for beginners, let’s pass the most commonly used echo command as an argument to the type command without any options.

$ type echo


Checking the type of echo command

As you can clearly see, the echo command is a shell built-in command and is interpreted in this way whenever it is executed.

Note that you are not limited to passing a single command; you can pass multiple commands to the type command at the same time to find their actual types.

$ type ls cp if


Checking the type of multiple commands

In the above picture, it states that β€œls” is an alias for the β€œls --color=auto” command. Check out our article on the ls command and creating shortcuts in Linux to know why.

The cp command is referring to the β€œ/usr/bin/cp” binary, and β€œif” is a shell keyword (mostly used in shell scripting).

Trim the Type Command Output

Instead of getting the extra information in the output, you can trim the results into just the type of the command using the β€œ-t” flag.

The following is the list of known command types:

  • Alias
  • Builtin
  • File
  • Function
  • Keyword

The following is an example of when a single command is passed to a type command with the β€œ-t” flag.

$ type -t echo


Short description of the echo command

The following is an example when multiple commands are passed to type command with β€œ-t” flag.

$ type -t ls cp if


Short description for multiple commands

Force Type to Return the Path of the Referenced Command

If you are only interested in finding the executable path of the referenced command without worrying whether its built-in shells or aliases, then you can use the β€œ-P” flag.

$ type -P echo


Only return the executable path of the referenced command

When you pass the mixtures of multiple commands to find their executable path you will get the following results.

$ type -P ls cp if


Returning executable path for multiple commands

As you can clearly see from the above picture, the executable paths for the ls and cp commands return in output, except for β€œifβ€œ, which is a shell keyword and not an executable file.

Getting More Information About the Referenced Command

The β€œ-a” flag is useful when you want to know the type of the command and all the places where the referenced command (executable file) can be found.

In the following example, the echo command is being passed with the β€œ-a” flag.

$ type -a ls


Getting more information about the ls command

You will get a combination of mixed results when you pass the multiple commands with the β€œ-a” flag.

$ type -a ls cp if


Getting more information about multiple commands

What Does β€œCommand is Hashed” Mean in the Output?

Sometimes, when you check the type of the referenced command, you might end up getting β€œcommand is hashed” along with the path in the output.

$ type man


Command is hashed

The reason for this output, even though it may only occasionally occur, is that your shell keeps a record of every executable program that it has ever discovered in a list known as the hash list.

This way, the shell avoids wasting time searching for the path of an executable by returning the results from previous searches, even though you can use the β€œhash -r” command to force the shell to start searching from scratch.


If you read the complete article, then you realize how useful and handy this tool can be when you want to determine the command type or how it’s acting in a certain way.

If you have questions or queries related to this topic, then feel free to ask them in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.