Commands to Find Folders in Linux

The command to find a folder in Linux is the find command.

The operation method of the Linux-file search command find is as follows:

1. Search across the entire disk, or specify a directory search. find search directory -name target name:

find / -name file

 2. In this way, what you see in the search is the exact match of the file, which is case-sensitive, and you can use -iname to not be case-sensitive. In this way, we can find more relevant files in uppercase.

find / -iname file

 3. We first use the * wildcard to match related files that contain file. If you match in this way, there will be more files, and the more accurate the match, the easier it is to find.

区分大小写的:

find / -name *file*


不区分大小写的:

find / -iname *file*

 4. find search directory -size file size.

下面我们查找下大于100MB的文件,应该实际是102400KB*2,所有搜索命令如下,-号是小于,直接写数字就是等于

find / -size +204800

 5. find search directory -user username. Here is to find the file belonging to the user named user1, how to add and delete the user name in Linux, you can refer to the Linux user management command

find / -user user1

 6. find search directory -type d. Find all directories under a directory.

find /tmp -type d

 7. find search directory -cmin -time (in minutes). Find files that have been modified within 1 hour under etc. There are too many under the root directory, so specify a directory.

find /etc -cmin -60

8. Of course, the find command can add multiple options together to query: -a means that both conditions must be met, and -o means that only one condition must be met, so that we can see the filtered files in a clear way. 

find /etc -cmin -60 -a -name *conf

 

Guess you like

Origin blog.csdn.net/wd520521/article/details/127965984