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