One Linux command per day (+): which

Source: Internet
Author: User

1. Introduction to Commands

which 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. In other words, you can use the which command to see if a system command exists and where the command is executed.

2. Usage
/usr/bin/which [options] [--] COMMAND [...]
3. Options
--version,-[VV "display version information --help, displaying Help information --skip-dot Skip Directories in   PATH that s  Tart with a dot. --skip-tilde Skip Directories in   PATH that  Start with a tilde. --show-dot don " t expand a dot to current Dir  Ectory in output.  --show-tilde Output A tilde for  HOME directory for
     non-root. --tty-only Stop processing options on the right if   Not on TTY.    --all,-a finds all matches instead of the first  
  --read-alias,-I read list of aliases from stdin.   --skip-alias     Ignore option--read-alias; Don't read stdin.  --read-functions Read Shell functions from stdin.   --skip-functions Ignore option--read-functions; Don't read stdin.
4. Example 1: View the default JDK
which Java/usr/bin/java
Example 2:which find the directory, the value of the PATH variable
Echo $PATH/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin :/root/bin
Example 3: The specific alias information is listed when you look up a command that has an alias
which which  which='alias |/usr/bin/which--tty-only--read-alias--SHOW-DOT--show-tilde '    /usr/bin/which

Using which to find which, the result will be two which, one of which is alias this is called "command alias"

Instance 4:bash built-in command cannot be found such as CD command
which CD/usr/bin/which in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/ Local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

CD is not a common command to find, this is because the CD is built in bash commands! But which by default is to find the directory within the PATH, so of course not found!

One Linux command per day (+): which

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.