Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed introduction of Centos file search command

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the "detailed introduction of Centos file search commands" related knowledge, in the actual case of the operation process, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!

1. Locate--- > file to find the pre-generated database, fuzzy search, and updatedb to update the locate database

-I: ignore the case of the file name

-n: only the first n lines of eg:locate-n3passwd are displayed

2. Find---- > search in real time to match the file name exactly

Find [DIR...] [CRIERIA] [ACTION...]

DIR:/root/home.. (default current directory)

ACTION

-print (default)

-ls

-okCOMMAND interactive command execution

-execCOMMAND non-interactive execution command

Xargs executes and creates commands from standard output

Eg;find/root-name "[[: alpha:]] [[: digit:]]"-execmv {} {}\; / / {} represents the result of the previous search, and must end with\;

Find/root-name "[[: alpha:]] [[: digit:]]" | xargschmod755 |

CRIERIA:

-name: accurate to the specified file name

-iname: looks up by file name, but is not case-sensitive

-user: search according to the owner

-group: search by group

-uid: search based on uid

-gid: search based on gid

Look for in a specified period of time:

-atime: [+ / -] N (accesstime): +-indicates-(+)-Nmurmuri-(-)-currentday

Eg:find-atime-3-execls-l {}\

-mtime: (modificationtime) ditto

-ctime (changetime) ditto

-amin in sub-species, ditto

-mmin

-cmin

-anewera.txt has more recent 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 (linked file), f (normal file), s (socket file)

B (block device), c (character device), p (command pipeline file)

Eg:find/var-typel-execls-l {}\

-size: find by size

[+ / -] N

-perm [+ / -] mode searches based on permissions

Mode755

-222 each type of user should match.

Eg:find/tmp/myscrip-perm-001

/ 222 A user only needs to have one class of permissions

-nouser: no users

Eg:find/-nouser views files without user names. Generally speaking, such files are dangerous to some extent.

-nogroup: no group

Find conditional connections:

-a _ usually omitted

Eg:find-userroot-typef-execls-dl {}\

-o: | |

Eg:find-usernamed-o-typed-execls-ld {}\

-notorcake Pluto!

Eg:find-not\ (- typed-a-userroot\)-execls-ld {}\

-ls- l`find /-namepasswd`

File name wildcard: * any character,? Single character, []

Eg:find/tmp-namea*// looks for files that start with a

This is the end of the detailed introduction of the Centos file search command. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report