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

Use the which command of linux to find files

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

Share

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

This article will explain in detail about the use of linux's which command to find files. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

The function of the 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.

Operation and maintenance staff often use which commands in their daily work to check the existence of a system command, or to find out the specific location of the command.

Syntax format: which [parameters] [file]

Common parameters:

-n specifies the file name length, which must be greater than or equal to the longest file name of all files-p is the same as the-n parameter, but here includes the file path-w specifies the width of the field when output-V displays version information

Reference example

Find the file and display the command path:

[root@linuxcool ~] # which bash

/ bin/bash

[root@linuxcool ~] # which adduser

/ usr/sbin/adduser

Description: which is based on the user configuration of the PATH variable within the directory to search for runnable files! Therefore, the commands found in different PATH configurations are of course different!

Use which to find which:

[root@linuxcool ~] # which which

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

Explanation: there will be two which, one of which is alias, which is the so-called [command alias], meaning that entering which will be equal to the following string of commands! The real Bash built-in command cannot be found, such as the cd command:

[root@linuxcool ~] # which cd

Explanation: cd this commonly used command can not be found ah! 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!

View the default jdk:

[root@linuxcool ~] # which java

/ usr/bin/java

The directory looked up by which, the value of the PATH variable:

[root@linuxcool ~] # echo $PATH

/ usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin on the use of linux which command to find files to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can 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