Usually find the file in Linux is to use Whereis or locate first, or not to find after the search command. Below is a detailed description of the following three orders:
1. Whereis View the location of the file
Common parameters:
-B: Only binary files are found (executable files)
-S: source source files only
The Linux system records all the files in the system in a database file, and when you use the Whereis or locate command to find it, the contents of the database file are the same, so you sometimes find files that have been deleted when you find them with these two commands , and files that were built before the database update (which is updated once a week by default) will not be found and must be manually updated to the next database. To manually update the database file, you can use this command:
[Root@wxr/]# UpdateDB
The following Whereis command is in practice:
[Root@wxr/]# Whereis httpd.conf
HTTPD:/usr/sbin/httpd/usr/sbin/httpd.worker/etc/httpd/usr/lib/httpd/usr/share/man/man8/httpd.8.gz
[Root@wxr/]# Whereis-b httpd.conf
HTTPD:/USR/SBIN/HTTPD/USR/SBIN/HTTPD.WORKER/ETC/HTTPD/USR/LIB/HTTPD
But I don't know why Tomcat's boot file can't be found.
[Root@wxr/]# Whereis startup.sh
Startup
2. Locate with database view file location
Before using this command, you can first perform the update system file Database command described above, so that the files in the library are the freshest.
Continue with the following practice:
[ROOT@WXR/]# Locate httpd.conf
/etc/httpd/conf/httpd.conf
/usr/local/apache2/conf/.httpd.conf.swp
/usr/local/apache2/conf/httpd.conf
/usr/local/apache2/conf/original/httpd.conf
/usr/local/httpd-2.2.4/docs/conf/httpd.conf
/usr/local/httpd-2.2.4/docs/conf/httpd.conf.in
[ROOT@WXR/]# Locate startup.sh
/usr/local/apache-tomcat-6.0.26/bin/startup.sh
/usr/local/tomcat6/bin/startup.sh
3. Find search hard disk query file
Because this command is looking from the hard disk, the query speed is much slower than the two commands above. However, it has a lot of parameters, you can achieve more detailed query.
Practice:
[Root@wxr/]# Find/-name httpd.conf
/etc/httpd/conf/httpd.conf
/usr/local/apache2/conf/httpd.conf
/usr/local/apache2/conf/original/httpd.conf
/usr/local/httpd-2.2.4/docs/conf/httpd.conf
[Root@wxr/]# Find/-name startup.sh
/usr/local/apache-tomcat-6.0.26/bin/startup.sh
/usr/local/tomcat6/bin/startup.sh
Tips:
The above command query file, locate and find command file name can use wildcard characters (forget the file name when this method is useful oh ~), such as:
[ROOT@WXR/]# Locate *.conf
[Root@wxr/]# Find/etc-name *.conf