Linux File Names: which, whereis, locate
1. when you use find to query file names, the query speed is slow due to disk queries. Therefore, which, whereis, and locate are usually used for queries in linux. Because the query speed is very fast due to database queries. 2. which our commonly used ls commands. If we want to know where these commonly used commands are put, we can 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. whereiswhereis 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. locatelinux lists system files 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