find
1. The role of
the role of the find command is to search for files in a directory, its permissions for all users.
2. Format
find [path][options][expression]
path specifies the directory path from here to find the file system down the directory tree. It is a list of paths separated from each other by a space, if you do not write path, it defaults to the current directory.
3. The main parameters
[options] parameters:
the -depth: using deep-level discovery process mode, first search the contents of files in a specified directory level.
-Maxdepth levels: the first level represents up to find the level of subdirectories start directory. level is a non-negative, if the level is 0, then represent only look in the current directory.
-Mindepth levels: the first level represents the least level of subdirectories to find the beginning of the directory.
Find not in other file systems (such as Msdos, Vfat etc.) directories and files: -mount.
-Version: print version.
[expression] is a matching expression, a find command accepts an expression, all the operations of the find command is for expression. Its parameters are many, here only some of the commonly used parameters.
-Name: supports wildcards * and?.
-Atime n: search've read in the last n days file.
-Ctime n: search modified in the last n days file.
-Group grpoupname: search all group grpoupname file.
-User User name: to search for all files is owned by the username (ID or name) of the file.
-Size n: n is the size of a file search block files.
-Print: output search results, and print.
4. application skills
find command to find files in several ways:
(1) based on the file name lookup
for example, we want to find a file name is lilo.conf file, you can use the following command:
find / -name lilo.conf
"/" Means to search the entire hard disk after the find command.
(2) quickly find files
Find the file filename will encounter a real problem according to, it is to take a very long period of time, especially for large Linux file systems and large-capacity hard disk when the file is placed deep subdirectory. If we know that this file is stored in a directory, as long as this directory will save a lot of time looking down. For example smb.conf file from its file extension ".conf" This is based on a configuration file, then it should be in the / etc directory, then you can use the following commands:
find /etc -name smb.conf
In this way, use the "Find Files Fast" mode can shorten the time.
(3) Find Method according to part of the file name
Sometimes we just know that a file containing abvd these four words, then you want to find all files that contain the system has four characters you can enter the following command:
find / -name '*abvd*'
After entering this command, Linux system will search for all files containing abvd these four characters in the / directory. Where * is a wildcard, such as abvdrmyz and other eligible files can be displayed.
(4) using a hybrid to find ways to find files
You can use the find command to find a method of mixing, for example, we want to find greater than 500,000 bytes in the / etc directory and modify a file within 24 hours, you can use -and (and) Find the two parameters are linked Find a way to be combined into a hybrid.
find /etc -size +500000c -and -mtime +1