CentOS common commands to search for files

1. locate command

 Search by filename

Searches are fast, but not suitable for precise lookups. Generally not.

2. find command

1. find [scope ] [condition ] [filename ]

/ is the search scope, the root directory. Narrow the scope /root/ table root directory, etc.

-name is by name

Can't find it because it's not a fuzzy query. The file name should be specified

2. If you want fuzzy query, add wildcard

Wildcard: *

All files starting with algorithm are found

3. Wildcards?

One? Indicates that there is one character after the search algorithm

 

two? Indicates that there are two characters after the search algorithm

 

4. Wildcards * and ? Can be added anywhere in the keyword algorithm

 

5. Wildcard [ ]

Indicates that any character within [ ] can be found

 

 

6. Linux is case-sensitive. If the file name is lowercase, if the search is written in uppercase, it will not be found.

If it is not case sensitive just add an i before the name

 

 

7. The first few sections are based on the file name-name search, and can also be based on the user - user

   Find all files in the root user directory

 

 

8. -size Find according to the file size

命令 [root@localhost ~]# find /root/ -size 2k

2k means 1~2k

1k means 0~1k

+2k means greater than 2k

-2k means less than 2k

命令 [root@localhost ~]# find /root/ -size +10k –a –size -20k

Indicates to find files greater than 10k and less than 20k in the root directory

-a means and with

-o means or or

 

9. -inum Find according to the i node

[root@localhost ~]# ll –I show all i-node files

 

 

10. Search by time

-atime +n means files with access or execution time greater than n days

-ctime +n means write files with a change time greater than n days

-mtime +n means that files whose writing time is greater than n days are used the most

        -n means less than n days

 

3. grep command

Grep [string to look for ] [path ]

Find strings in configuration files in a directory

Options

-i ignore case

[root@localhost ~]# grep -i save /etc/grub2.cfg

-v exclude the specified string

[root@localhost ~]# grep -v save /etc/grub2.cfg

 

Fourth, the command search command whereis and which

1. whereis find files

whereis [options ] [filename ]

Option –b table finds only binary executables

-m table finds only help files (files in the man directory)

-s table finds only source code files

2, which finds the absolute path of the executable file

which [executable filename ]

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324747106&siteId=291194637