Centos file search command

Source: Internet
Author: User

1. locate ---> searches for the database generated in advance, fuzzy searches, and updatedb updates the locate database.
-I: Ignore the case sensitivity of file names.
-N: show only the first n rows eg: locate-n3passwd
2. find ----> real-time search, exact matching of file names
Find [DIR...] [CRIERIA] [ACTION...]
DIR:/root/home .. (default current directory)
ACTION;
-Print (default)
-Ls
-OkCOMMAND: Interactive Command Execution
-ExecCOMMAND: non-interactive Command Execution
Xargs executes and creates commands from standard output
Eg; find/root-name "[[: alpha:] [[: digit:]"-execmv {}{}\; // {} indicates the search result, which must end \;
Find/root-name "[[: alpha:] [[: digit:]" | xargschmod755
CRIERIA:
-Name: accurate to the specified file name
-Iname: search by file name, but case insensitive
-User: search by owner
-Group: search by group
-Uid: search by uid
-Gid: search by gid
In the specified time range:
-Atime: [+/-] N (accesstime): +-represents --- (+) ---- N --- (-) ---- currentday
Eg: find-atime-3-execls-l {}\;
-Mtime: (modificationtime) Same as above
-Ctime (changetime) is the same as above

-Amin is in the same unit as preceding.
-Mmin
-Cmin

-Anewera.txtcloser access than a.txt
Eg: find-anewersh01.sh-execls-l {}\;
-Newer is equivalent to modificationtime
-Cnewer is equivalent to changetime.
-Type: search by type
D (directory), l (link file), f (common file), s (socket file ),
B (Block device), c (character device), p (command pipeline file)
Eg: find/var-typel-execls-l {}\;
-Size: search by size
[+/-] N
-Perm [+/-] mode: Find Permissions
Mode755
-222 each type of user must match
Eg: find/tmp/myscrip-perm-001
/222 If a user has one type of permissions
-Nouser: No user
For example: find/-nouser to view files without a user name, this file is generally dangerous.
-Nogroup: No group


Search Condition connection:
-A: & generally can be omitted
Eg: find-userroot-typef-execls-dl {}\;
-O: |
Eg: find-usernamed-o-typed-execls-ld {}\;
-Notor! :!
Eg: find-not \ (-typed-a-userroot \)-execls-ld {}\;


-Ls-l 'Find/-namepasswd'

Wildcard file name: * any character ,? Single character, []
Eg: find/tmp-namea * // search for files starting with

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.