Linux which command details

Source: Internet
Author: User

Which command

Function Description: The which command is used to search for the location of a system command in the PATH specified by the PATH variable and return the first search result. That is to say, you can use the which command to check whether a system command exists and where the command is executed. If you want to know where your command is stored, use which to find it. Of course, you need to note that it is in the PATH specified by the PATH. The PATH of common users and Super Users is different (without modification ).

Syntax which executable file name

Parameters

-N: the length of the specified file name must be greater than or equal to the longest file name in all files.

The-p and-n parameters are the same, but the file path is included here.

-A lists more than the first commands in the PATH directory.

-W specifies the width of the field when the output is made.

-V: display version information

Use instance

Find common command paths

[Atong @ LiWenTong tmp] $ which pwd

/Bin/pwd

 

Specific alias information is listed when you search for commands with aliases.

[Atong @ LiWenTong tmp] $ which ls

Alias ls = 'ls -- color = tty'

/Bin/ls

 

The search command does not include ifconfig in the PATH of a common user.

[Atong @ LiWenTong tmp] $ which ifconfig

/Usr/bin/which: no ifconfig in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin: /home/atong/bin)

 

Bash built-in commands cannot find cd commands.

[Atong @ LiWenTong tmp] $ which cd

/Usr/bin/which: no cd in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:

 

 

PATH for common users

The user's PATH is different from the root PATH. To be the same, edit the bash_profile file in the user's home directory to add/user/local/sbin:/user/sbin.

 

------------------------------ Subsequent self-Summary -----------------------------

The which command is used to find out where the command is located. If the command does not exist, which cannot be found. Another one is that we are looking for the PATH stored in the PATH. This parameter is in the/etc/profile file. This is a global user, and each user has its own file. Oh, I forgot it for a moment. In ~ In the. profile file in the home directory.

Some command paths of the software we installed can also be incorporated into the PATH so that the commands of the software we installed can also be found and can be directly executed without the full PATH.

-----------------------------------------------------------------------

Linux which command parameters and usage --- Linux File SEARCH Command

Search for files in Linux -- type whereis which find locate

RHCE_RHEL6_135 U4.0 find and process files which & locate & find

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.