How to Use the Linux type Command

Terminal on a Linux laptopFatmawati Achmad Zaenuri /

Determine whether a command resolves an alias, disk file, shell function, built-in command, or reserved word. Use type to discover how your Linux commands are executed and better understand your system.

Make my offer

When we open a terminal window and start issuing commands on our Linux computer, we rarely stop thinking about the operating system software components that respond to our commands and execute them for us. We type the command, get the result and move on to the workload.

Knowing how commands are executed allows us to better understand how our Linux operating system or other Unix type is built. Having a look under the hood can make us a more informed driver.

The instructions we send to the command line belong to one of the following categories:

Alias: command defined by the user (or system) that causes other command sequences, usually long or complex.
Disk file: A binary executable file, such as / usr / bin / top.
Shell function: A user-defined function (or system) that can be used on the command line or included in scripts.
Built-in command: command executed by the shell itself, such as pwd.
Reserved word: word reserved by the shell, such as if and elif. They are also called keywords.

The typical order tell us which category No matter which of the Linux commands belongs to. Here is a quick tutorial to understand the result of the command.

The type of order

Let's review a few quick examples for each of the order categories.

date type

type the date in a terminal window

The date command is an executable disk file.

type ls

type ls in a terminal window

The ls command is an alias, which encapsulates the underlying ls command to use the default –color = auto option.

type lowdown

type lowdown in a terminal window

The lowdown command is a user-defined function that has been configured on the commuter used to search for this article. It provides a quick snapshot of some system resources. This is a combination of whoami, w, free and df.

type pwd

type pwd in a terminal window

The pwd command is an integrated command of the Bash shell.

elif type

type elif in a terminal window

The elif command is a reserved word of the Bash shell.

Using multiple commands

You can give several commands to type to identify at the same time.

type date top ls

type date top ls in a terminal window

The -t option

None of the options of this type will accept names. So we can take out our book of names and baptize them ourselves. If you think that the -t option is synonymous with "laconic", you will not go wrong. It reduces type responses to one-word answers.

type -t date
type -t pwd
type -t lowdown

demonstration of the type -t option in a terminal window

The -a option

Let's call this one the "all" option. It lists all the locations in which the command is located. Note that this option will not work if you also use the -p option.

For example, if you have an alias with the same name as the underlying command, you can get information about the alias and the command.

type -a ls

demonstration of the type -a option in a terminal window

The -f option

The -f option forces the type not to look for functions defined by the user or the system. Consider this option as "function search disabled". Note that if the command is a function, type will signal that the command is not found.

type -f top
type -f lowdown

demonstration of the type -f option in a terminal window

The -P option

If you use the -P option, the type will only look for the directories in $ PATH. We can therefore call this option "path". Note that this option uses a capital "P.".

type -P date chmod adduser

type -P date chmod adduser in a terminal window

The -p option

If you use the -p option, the type only responds if the command is a hard disk file. Note that this option uses a lowercase "p".

type -p mount
type -p ls
type -p -a ls

demonstration of the type-p option in a terminal widow

type gives no response for ls because it is an alias and not a disk file.

But if we include the -a option so that type looks for all instances of the ls command, it lists the underlying disk file used by the ls alias.


It was nice and simple, but enlightening anyway.

We tend to think that everything we type in a terminal window is a "command", and we're left there. But in reality, the commands are implemented in different ways in the Linux system. And typing lets you know which one it is.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.