Find which, whereis, locate,

Source: Internet
Author: User

Find which, whereis, locate,
1. Search for file names
The query speed is slow due to disk queries. Therefore, which, whereis, and locate are usually used for queries in linux. The query speed is fast because the query speed is based on the database.
2. which
We commonly use ls commands. If we want to know where these commonly used commands are put, use the which command to query the address. Which uses the PATH environment variable to find the file name. which-a returns all the commands found. The first command is returned by default.

$ Which grep/bin/grep $ which llalias ll = 'LS-l -- color = tty '/bin/ls # Use alias

3. whereis
Whereis is used to query the program name
$ Whereiswhereis [-sbmu] [-SBM dir... -f] name... -B: Find the binary file-s: Find the source file-m: Find the file in the manual path of the description file-u: Find a special file that is not in the preceding three options
For example
$ Whereis grepgrep:/bin/grep/usr/share/man/man1/grep.1.gz/usr/share/man/man1p/grep.1p.gz # query the binary file $ whereis-B grep: /bin/grep # query the manual instruction file man grep $ whereis-m grepgrep:/usr/share/man/man1/grep.1.gz/usr/share/man/man1p/grep.1p.gz

3. locate
In linux, files in the system are listed in a database file (/var/lib/slocate. db ). Locate is queried by database files.
Generally, this file is updated every day and configured in/etc/updatedb. conf to check whether the file is updated every day and update the directory. Run manually
$ updatedb
To update the database. Use locate, followed by the command
$ locate passwd

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




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.