Get the App
SLTechnology News&Howtos  ›  Development  › 

Case Analysis using type Command

Shulou Source: shulou.com Published: 2022-06-01 14:32:49 09月10日 Update

This article mainly introduces the relevant knowledge of "type command use case analysis". The editor shows you the operation process through the actual case, and the operation method is simple, fast and practical. I hope this "type command use case analysis" article can help you solve the problem.

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.

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 introduction of $man type on "type command usage example analysis". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Command content alias type instance instance analysis analysis instruction knowledge information method more industry path different medium practical dangerous for this purpose use method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno Xiaomi Redmi MySQL