Linux file name lookup which,whereis,locate

Source: Internet
Author: User

1. File name Lookup
When using the Find query, because the disk query, so slow, so the Linux query more often use which, whereis, locate to query, because it is the use of database queries, so fast.
2. Which
Our common ls command, if we want to know where these common 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
For example
$ 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 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.
Generally this file is updated daily, configured in/etc/updatedb.conf to configure whether to update daily, and update the directory. can be run manually
$ updatedb
To update the database. Use locate, followed by commands
$ locate passwd

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

Linux file name lookup which,whereis,locate

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.