1, which
Function: View the location of the executable file (through the PATH environment variable to find the executable file)
Syntax: which executable file name
Example:
which passwd/usr/bin/passwd
2, Whereis
Role: View the location of a file
Syntax: Whereis [-BMSU] file or directory name
Parameter description:
-B: Only binary files are found
-M: Only files found under the manual path of the description file
-S: Find source files only
-u: File without document description
Example:
Whereis passwd passwd:/usr/bin/passwd /etc/passwd /usr/bin/x11/ passwd/usr/share/man /man1/passwd. 1. gz/usr/share/man/man1/passwd1ssl.gz/usr/share/man/man5/passwd . 5. gz
Whereis looks very fast compared to find, because the Linux system records all the files in the system in a single database file, and when you use Whereis and the locate described below, the data is looked up from the database, not like the Find command, By traversing the hard drive to find, the efficiency will naturally be very high. However, the database file is not updated in real time and is updated once a week by default, so when we use Whereis and locate to find files, we sometimes find data that has been deleted, or just created the file, but cannot find it because the database file is not updated.
3, locate
Role: View file location with database
Syntax: Locate file or directory name
Example:
[Email protected]:/$Locate passwd/etc/passwd/etc/passwd-/etc/cron.daily/passwd/etc/init/passwd. conf. (Omit large segment)/var/lib/dpkg/Info/passwd. Conffiles/var/lib/dpkg/Info/passwd. List/var/lib/dpkg/Info/passwd. Md5sums/var/lib/dpkg/Info/passwd. Postinst/var/lib/dpkg/Info/passwd. preinst
4. Find
Function: Actual search hard disk query file name
Syntax: Find Path parameter
Parameter description:
Time Lookup Parameters:
-atime N: Lists the files accessed within the n*24 hours
-ctime N: List the changes, additions, or directories in n*24 hours
-mtime N: Lists files or directories that have been modified within n*24 hours
-newer file: List files that are newer than
Name Lookup parameters:
-gid N: Looking for a file with group ID n
-group Name: Find a file with the name of the group
-uid N: Looking for a file with owner ID n
-user Name: Find a file with the user name called name
-name file: Look for files named file (wildcard characters can be used)
Example:
Find ' *passwd* '/etc/pam.d/chpasswd/etc/pam.d/passwd/etc/init/passwd. conf/etc/ cron.daily/passwd/etc/security/opasswd/etc/passwd-/etc/passwd...
The difference between which, whereis, locate, and find commands under Linux