First, Whereis < program name > find Software Installation path
-B finds only binary files-m only find help files
-S find source code only
-U excludes the specified type file
-F Show file name only
-B < directories > Find binaries in the specified directory
-M < directory > Find help files in the specified directory
-S < directory > find source code under specified directory
Second, locate < file name >
Searching for files in the file index database
-D < database path > search for specified database
UpdateDB
Update file Index Database
Third, find [path] < expressions >
Find Files
-name < expressions > Find files by file name
-iname < expressions > Find files by file name, ignoring case
-path < expressions > Find files by Path
-ipath < expressions > Find files by path, ignoring case
-amin < min > Files accessed in the last n minutes
-atime < days > Files accessed in the last n days
-cmin < minutes > modified files in the last n minutes
-ctime < days > Files modified in the last n days
-anewer < reference files > files that have been read later than the referenced file
-cnewer < reference files > files that have been modified later than the referenced file
-size < size > Find files based on file size, Unit b C w K M G
-type < file type > Find files by file type. B Block device c character device D catalog p pipe file f normal file L link s port file
-user < username > Find files by attribution user
-uid <uid> Find files by uid
-group < Group name > Find files by attribution Group
-gid <gid> find files by gid
-empty Finding empty files
The system immediately displays httpd.conf file information on the screen after finding the httpd.conf file.
Find/-name "httpd.conf"-ls
Find a file under the root directory
Find. -name "Test"
Iv. grep command
Find matches the specified string from the file contents of the line $ grep "The string being looked up" file name
Find the line that matches the regular expression from the file contents:
$ grep–e "Regular expression" file name
Find is case insensitive:
$ grep–i "string found" file name
To find the number of matching rows:
$ grep-c "string found" file name
Find rows that do not match the specified string from the file contents:
$ grep–v "string found" file name
From the root directory, look for all text files with a. log extension and find the line that contains "ERROR"
Find/-type f-name "*.log" | Xargs grep "ERROR"
Find a file containing a string in a directory
Grep-r "ZH_CN".
Common commands for finding files and file contents in Linux