Linux Command Learning Note (+): which command

Source: Internet
Author: User

we often find a file in Linux, but do not know where to put it, you can use some of the following commands to search:whichView the location of the executable file. WhereisView the location of the file. LocateView the file location with the database. Findactual search hard disk query file name. The purpose 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. That is, with the which command, you can see whether a system command exists, and the command that executes exactly which location. 1. Command format:whichexecutable file name2. Command function: The which directive 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 in all files. -P and-The n parameter is the same, but the path to the file is included here. -WSpecifies the width of the field at the output. -V display version information4. Use instance: Instance 1: Find file, show command path command:which Lsmod[[Email protected]~]#which pwd/bin/pwd[[Email protected]~]#whichAddUser/usr/sbin/Adduser[[email protected]~] #说明:whichis to search for a running file based on the directory within the PATH variable that the user has configured! Therefore, the different PATH configuration content found the command of course not the same! Example 2: UsingwhichTo find outwhichcommand:which which[[Email protected]~]#which whichaliaswhich='alias |/usr/bin/which--tty-only--read-alias--SHOW-DOT--show-tilde'/usr/bin/which[[Email protected]~] #说明: There's going to be two of them.which, one of which is alias, which is called the "command alias", which means the inputwhichwill be waiting for the next sequence of orders! Example 3: Find the CD this command command:whichCD Description: cd this common command can not find Ah! Why is it? This is because the CD is a command built in bash! ButwhichThe default is to find the PATH within the standard directory, so certainly can not find! 

Linux Command Learning Note (+): which command

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.