8. File search

One, locate command to find files

The locate command is to search by file name in the background database, the search speed is fast, non-real-time.

1. Install mlocate

yum -y install mlocate

2. Update the database

updatedb

3. Find files

locate ifcfg-eth0
8. File search

Two, whereis and which

1、whereis

whereis find command path and help file
8. File search

whereis -b cmd // return command path
8. File search

whereis -m cmd // return the help file path
8. File search

2、which

which cmd returns the command path
8. File search

Three, Find to find files

1. Basic syntax of find command

find path option expression action

Find according to file size
// Find files with a file size greater than 5M in the /etc directory
find /etc/ -size +5M
8. File search

Find according to the file type
// Find the block device file in the /dev directory
find /dev -type b
8. File search

Find according to time
//Find files 7 days ago in the user's home directory
8. File search

According to the user search
// Find the file in the centos home directory
find /home/centos -user centos
8. File search

Find according to permissions
// Find 755 permission files
find ./shell_scripts/ -perm 755 -ls
8. File search

2. Find processing action

-print: print the found content (default)
-ls : print the found content in a long format display
8. File search
-delete: delete the found file (only empty directories can be deleted)
-ok: followed by a custom Shell command ( Will prompt whether to operate)
8. File search
-exec: followed by a custom Shell command (standard writing -exec \;)
8. File search

Guess you like

Origin blog.51cto.com/12631595/2666766