How to Use the find command in Linux

Source: Internet
Author: User

The Linux find command is used to search for files. Skilled in using this command can help us quickly find the files we need, you can have time, user group, file permissions, and additional operation parameters to help you quickly perform search.

Find command

1. Time-related commands
-Atime n: n is a number that indicates the files that have been accessed within one day before n days.
-Ctime n: n is a number that indicates a file in the "changed" status within one day before n days.
-Mtime n: n is a number that indicates a File Modified (modification) within a day before n days.
-Newer file: file is an existing file, which means that as long as the file is newer than file, it will be listed.

2. parameters related to the user or user group name:
-Uid n: n is a number. This number is the user's account ID, that is, UID. This UID is recorded in the number corresponding to the account name in/etc/passwd.
-Gid n: n is a number. This number is the ID of the user group name, that is, GID. This GID is recorded in/etc/group.
-User name: name indicates the user account name, for example, dmtsai.
-Group name: name indicates the user group name, for example, users.
-Nouser: the owner of the file is not in/etc/passwd.
-Nogroup: searches for files whose owner is not in the/etc/group.

3. parameters related to file permissions and names:
-Name filename: searches for files with filename names.
-Size [+-] SIZE: Search for files that are larger (+) or smaller (-) than the SIZE. The SIZE specifications include: c: bytes, k: indicates 1024 bytes. Therefore, to find a file larger than 50 kb, it is "-size + 50 K"
-Type TYPE: the TYPE of the search file. The types include: General Regular files (f), device files (B, c), directories (d ), connection file (l), socket (s), and FIFO (p) attributes.
-Perm mode: searches for files with the File Attribute "exactly equal to" mode ". This mode is similar to the chmod attribute value. For example, if the attribute of-rwsr-xr-x is 4755, it will also be listed.
-Perm-mode: searches for objects whose file attributes "must all include the mode attributes". For example, you need to search for a file named-rwxr -- r --, that is, a file named 0744, -perm-0744 is used. When the attribute of a file is-rwxr -- r --, that is, 4755, it is also listed, because-rwxr-xr-x has included the "-rwxr -- r --" attribute.
-Perm + mode: searches for files whose file attributes "include attributes of any mode". For example, when-rwxr-xr-x is searched, that is,-perm + 755, but a file whose property is-rw ------- will also be listed because it has-rw .....

4. Additional operations:
-Exec command: command is another command.-exec can be followed by an additional command to process the search results.
-Print: print the result. This action is the default action.

The above is a detailed analysis of the Linux find command, parameter introduction.

  1. Comprehensive parsing of Linux profile files
  2. Detailed analysis of how to use the Linux df command
  3. Explain how to use chgrp and chown commands in Linux
  4. In-depth analysis of Linux partition Basics
  5. Differences between Linux and Unix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.