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

The usage of which command in linux

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

Share

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

This article mainly explains "the usage of which command in linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the usage of the which command in linux.

1. Command format:

Which executable name

2. Command function:

The which instruction searches for the location of a system command in the path specified by the PATH variable and returns the first search result.

3. Command parameters:

-n specifies the length of the file name, which must be greater than or equal to the longest file name of all files.

The-p parameter is the same as the-n parameter, but here the path to the file is included.

-w specifies the width of the field on output.

-V displays version information

4. Use an example:

Example 1: find files and display command paths

Command:

Which lsmod

Output:

The code is as follows:

[root@localhost ~] # which pwd

/ bin/pwd

[root@localhost ~] # which adduser

/ usr/sbin/adduser

[root@localhost ~] #

Description:

Which searches for runnable files according to the directories in the PATH variables configured by the user! Therefore, the commands found in different PATH configurations are of course different!

Example 2: use which to find out which

Command:

Which which

Output:

The code is as follows:

[root@localhost ~] # which which

Alias which='alias | / usr/bin/which-tty-only-read-alias-show-dot-show-tilde'

/ usr/bin/which

[root@localhost ~] #

Description:

Unexpectedly, there will be two which, one of which is alias, which is the so-called "command alias", which means that typing which will be equal to the following string of commands!

At this point, I believe you have a deeper understanding of "the use of the which command in linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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