Linux file name lookup which,whereis,locate

Source: Internet
Author: User

1. File name Lookup
When you use the Find query. Because of a disk query. Therefore, the speed is relatively slow. So Linux under query more often use which, whereis, locate to query, because is the use of database queries. So the speed is very fast.
2. Which
We often use the LS command. Let's say we want to know where these often use commands are placed. Use the which command to query the address. which uses the PATH environment variable to find the file name, WHICH-A returns all the found commands, and returns the first one by default.

$ which grep/bin/grep$ which Llalias ll= ' ls-l--color=tty '        /bin/ls        #使用alias别名

3. Whereis
Whereis used to query the program name
$ whereiswhereis [-SBMU] [-SBM dir ...-f] name...-b: Find binary Format file-S: Find source file-M: Find file under Description file manual path-u: Find not above three Special files in the options
Like what
$ whereis grepgrep:/bin/grep/usr/share/man/man1/grep.1.gz/usr/share/man/man1p/grep.1p.gz# query binary file $ whereis-b grep grep:/bin/grep# Query Manual manual description file man grep $ whereis-m grepgrep:/usr/share/man/man1/grep.1.gz/usr/share/man/man1p/grep.1p.gz

3. Locate
Linux lists the in-system files in a database file (/var/lib/slocate/slocate.db). Locate is queried through the database file.
This file is usually updated daily. Configure whether the configuration is updated daily in/etc/updatedb.conf. and update folders. Ability to perform manually
$ updatedb
To update the database.

Use locate. You can follow the instructions later.

$ locate passwd

Address: http://blog.csdn.net/yonggang7/article/details/37960767

Linux file name lookup which,whereis,locate

Related Article

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.