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

How to use find command in linux system

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

Share

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

Linux system how to use find commands, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Find the file MyCProgram.c in the current directory and subdirectory

# find. -name "MyCProgram.c"

Find files and ignore case

# find. -iname "MyCProgram.c"

Find files that do not contain MyCProgram.c

Find. -maxdepth 1-not-iname "MyCProgram.c"

Look for passwd in / subdirectories at levels 3 to 5 below

# find /-mindepth 3-maxdepth 5-name passwd

Find and execute commands

Find. -iname "MyCProgram.c"-exec md5sum {}\

Find files greater than 100m

# find ~-size + 100m

Find files less than 100m

# find ~-size-100m

Find files equal to 100m

# find ~-size 100m

Find the largest 5 files in directories and subdirectories

Find. -type f-exec ls-s {}\; | sort-n-r | head-5

Find the smallest 5 files in directories and subdirectories

# find. -type f-exec ls-s {}\; | sort-n | head-5

Find 5 files with non-zero and smallest size

# find. -not-empty-type f-exec ls-s {}\; | sort-n | head-5

Find files where all users have write permissions

# find. -perm-Grouw-type f-exec ls-l {}\

Find files in the / logs directory that were changed before 5 days and delete them

$find logs-type f-mtime + 5-exec rm {}\

Look for ordinary files in the / var/logs directory that were changed before 7 days and ask them before deleting them

$find / var/logs-type f-mtime + 7-ok rm {}\

You can use some kind of filename pattern to match files. Remember to enclose the filename pattern in quotation marks, otherwise the matching expansion will lead to confusion of find parameters.

$find. -name [Amurz] *-print

Find files with a file permission bit of 755 in the current directory, that is, files that can be read, written and executed by the file owner, and that can be read and executed by other users.

$find. -perm 755-print

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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