Categories: How-To

Linux type command (describes something) [Basic Guide]

The type command in Linux is used to describe a name entered as a parameter, such as an internal bash command, program, function, nickname, or file. If no name is provided, it doesn’t do anything.

The type command is generally used to find out information about a Linux command. You can easily find out if the command provided is an alias, embedded shell, file, function, or keyword using the “type” command. In addition, you can also find the actual path of the command.

Why would someone need to find the command “type”? For example, if you happen to work on a frequently shared computer, someone may intentionally or accidentally create an alias for a particular Linux command to perform an unwanted operation, for example “alias ls = rm -rf/”. So it’s always a good idea to inspect them before anything worse happens. This is where the type command comes in handy.

Examples:

$ type bash bash is /usr/bin/bash

$ type ll ll is aliased to `ls -l --color=auto'

$ type for
For is a shell keyword

$ type -t ls
alias

$ type -t mkdir
File

$ type -t pwd
Builtin

$ type -t if
Keyword

$ type -t rvm

Function

The other useful advantage of the type command is that we can easily discover the absolute path of a given Linux command. To do this, use the “-p” option as shown below:

$ type -p cal
/usr/bin/cal

This example is similar to the ‘which ls’ command. If the given command is aliased, nothing will be printed.

To view all information about a command, use the “-a” option:

$ type -to ls
ls is aliased to `ls --color=auto'
ls is /usr/bin/ls
ls is /bin/ls

Conclusion

If you need to know about a particular command, you can use the type to describe whether the command is internal to the shell, a program, or an alias.

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Share
Published by
Uirá Endy Ribeiro

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.