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 which command on Linux system

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the Linux system which command how to use, the article is very detailed, has a certain reference value, interested friends must read it!

The main function of the Linux system which command is to search for the location of a system command in the path specified by the PATH variable and return the first search result.

Syntax which [file...] Parameter:-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.

Case demonstration: example 1: find files and display command paths

Command:

Which lsmod

Output:

[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:

[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!

Example 3: find out the command cd

Command:

Which cd

Output:

Description:

The common command of cd can't be found! Why? This is because cd is a built-in command from bash! But which defaults to find the directory specified in PATH, so of course you can't find it!

The above is all the contents of this article entitled "how to use which commands in Linux system". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report