Home  >  Article  >  Operation and Maintenance  >  How to use find command under linux

How to use find command under linux

王林
王林Original
2020-06-29 11:16:023310browse

The usage format of the find command under Linux: [find [find directory] [find rules]]. We can search for files by file name, such as [find /etc -name "*.conf"], which means finding files ending with [.conf] in the etc directory.

How to use find command under linux

find command

(recommended learning: linux tutorial)

find command usage format :

find  [指定查找目录]    [查找规则]  [查找完后执行的action]

Note: Directories must be separated by spaces.

Search rules:

(1) Search based on the file name

#  -name    //根据文件名查找(精确查找)
#  -iname    //根据文件名查找,但是不区分大小写

How to use find command under linux

##This is to use find to find the etc directory with [. conf] at the end of the file.

Another example, use find to find files starting with c or d and ending with f in the etc directory.

find /etc -uname [c,d]*f

(2) Find the file based on the user and group to which the file belongs

#  -user         //根据属主来查找文件
#  -group        //根据属组来查找文件

(3) Find the user based on uid and gid

#find  /tmp  -uid  500  //查找uid是500 的文件
#find  /tmp  -gid  500// 查找gid是1000的文件

The above is the detailed content of How to use find command under linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn