Common Linux commands (15th) and common linux commands

Source: Internet
Author: User

Common Linux commands (15th) and common linux commands

We often search for a file in linux, but do not know where it is stored. You can use the following commands to search:

Which: view the location of the executable file.
Whereis view the file location.
Use locate with the database to view the file location.
Find actual search hard disk Query file name.


1.Command Format:

Which Executable File Name


2.Command function:

The role of the which command: In the PATH specified by the PATH variable, search for the location of a system command and return the first search result. That is to say, by using the which command, you can see whether a system command exists and where the command is executed.


3.Command parameters:

-N indicates the length of the file name. The specified length 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.

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

-V: display version information

4. Command example:

Instance 1:Find the file and display the command path

Command: where pwd

[root@localhost ~]# which pwd/bin/pwd[root@localhost ~]# which rm/bin/rm

Which searches for executable files based on the directory in the PATH variable configured by the user! Therefore, the command paths found for different PATH configurations are certainly different!


Example 2:Use which to find which

Command: which

[root@localhost ~]# which whichalias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'     /usr/bin/which[root@localhost ~]#

There are actually two which, one of which is alias. This is the so-called "command alias", which means that the input of which will wait for the subsequent commands!


Example 3:Find the cd command

Command: which cd

[root@localhost ~]$ which cd/usr/bin/which: no cd in (/usr/local/ant/bin:/usr/local/jdk/bin:/home/oracle/software/product/client/10.2/bin:/usr/local/jdk/bin:/usr/local/ant/bin:/usr/local/ant/bin:/usr/local/jdk/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:.:/home/psc/bin:/home/psc/bin)[root@localhost ~]$
Because cd is a built-in bash command! However, by default, which finds the standard directory in the PATH, so of course it cannot be found!
Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.