Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use type command in linux system

Shulou Source: shulou.com Published: 2022-06-01 14:57:02 09月25日 Update

This article mainly shows you "how to use type commands in the linux system", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use type commands in the linux system" this article.

The type command is used to display the type of specified command and to determine whether the instruction given is an internal instruction or an external instruction.

How to use the type command

The type command is built into bash, and the type syntax:

Type [- afptP] [name...]

For example, look at the type of type:

[root@localhost ~] # type typetype is a shell builtin

You can also provide multiple parameters:

Type of [root@localhost ~] # type vim sleep headvim is hashed (/ usr/bin/vim) sleep is / usr/bin/sleephead is / usr/bin/head command

The-t option tells type to print a word describing the type of command, which will be one of the following:

Alias-alias builtin-built-in command file-file keyword-keyword

Here are some examples:

Alias [root@localhost ~] # type-t lsalias# in the Centos system, the command corresponding to the ls alias is ls-- color=auto [root@localhost bin] # type lsls is aliased to `ls-- color=auto'Builtin [root@localhost ~] # type-t printfbuiltin

Printf is a built-in command for shell

File [root@localhost ~] # type-t awkfile

Awk is an executable file

Keyword [root@localhost ~] # type-t whilekeyword

While, for, if, else. Wait, it's a reserved keyword in Bash.

Displays the location and type of the command

Use the-a command to display the location and type of the command:

[root@localhost ~] # type-a lsprintf awk whilels is aliased to `ls-- color=auto'ls is / usr/bin/lsprintf is a shell builtinprintf is / usr/bin/printfawk is / usr/bin/awkwhile is a shell keyword

This example shows the type and location of the ls,printf,awk,while command after execution.

The above is all the contents of the article "how to use type commands in linux system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Commands types systems locations contents instructions articles keywords keywords aliases words files learning help examples parameters multiple examples easy to understand more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux MariaDB Shulou Tech Info OPPO Reno