Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the type command in Linux

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to use the type command in Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

The type command is used to find information about the Linux command. As the name implies, you can easily use the type command to find out whether a given command is an alias, shell built-in command, file, function, or keyword. In addition, you can also find the actual path to the command. Why does anyone need to find the command type? For example, if you often work on a shared computer, someone may intentionally or accidentally create aliases for specific Linux commands to perform unwanted operations, such as alias ls = rm-rf /. So it's always a good idea to check them before something worse happens. This is where the type command is useful.

Let me show you some examples.

Run the type command without any options.

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

As you can see in the output above, the ls command has been aliased as ls-color-auto. But it's harmless. But just think about ls if it is aliased for some other dangerous command. You don't want that, do you?

You can use the-t option to find out only the type of Linux command. For example:

$type-t lsalias $type-t mkdirfile $type-t pwdbuiltin $type-t ifkeyword $type-t rvmfunction

This command displays only the type of command, such as an alias. It does not display content that is aliased. If the command cannot be found, you will not see anything in the terminal.

Another useful thing about the type command is that we can easily find the absolute path to a given Linux command. To do this, use the-p option, as shown below.

$type-p cal/usr/bin/cal

This is similar to the which ls command. If the given command is an alias, nothing is printed.

To display all the information about the command, use the-an option.

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

As you can see, the-a flag shows the type of given command and its absolute path. For more details, see the man pages.

This is the end of the man type article on "how to use type commands in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report