Home > System Tutorial > LINUX > body text

Commonly used Find command examples under Linux: 33 cases

WBOY
Release: 2024-01-02 18:34:27
forward
1150 people have browsed it
1. Find the name of the file in the current directory

In the current directory, find all files named linuxprobe.txt

# find . -name linuxprobe.txt
./linuxprobe.txt
Copy after login
2. Find files in the home directory

Find all files named linuxprobe.txt in the home directory

# find /home -name linuxprobe.txt
/home/linuxprobe.txt
Copy after login
3. Find files ignoring the case of file names

Search for a file named linuxprobe.txt in a specific directory, ignoring the case of the file name

# find /home -iname linuxprobe.txt
./linuxprobe.txt
./Linuxprobe.txt
Copy after login
4. Find a specific directory

Look for a directory named linuxprobe in the root directory

# find / -type d -name linuxprobe
/linuxprobe
Copy after login
5. Find the php file in the specified directory

Find the file named linuxprobe.php in the current directory

# find . -type f -name linuxprobe.php
./linuxprobe.php
Copy after login
6. Find all PHP files in the specified directory
# find . -type f -name "*.php"
./linuxprobe.php
./login.php
./index.php
Copy after login
7. Find files with permission 777

Find all files with permission 777 in the current directory

# find . -type f -perm 0777 -print
Copy after login
8. Find files with permissions other than 777

Find all files in the root directory with permissions other than 777

# find / -type f ! -perm 777
Copy after login
9.查找权限为664的文件
# find / -perm 2644
Copy after login
10.查找到文件大小为100M的文件并删除
# find / -size +100M -exec rm -rf {} \;
Copy after login
11.找到SUID文件
# find / -perm /u=s
# find / -perm /g=s
Copy after login
12.查找文件类型为mp3格式并且大小为100M的文件,然后删除
# find / -type f -name *.mp3 -size +10M -exec rm {} \;

#常用find操作,通过find出指定目录下的特定类型特定名称的文件,然后进行修改,移动,删除等操作。
Copy after login
13.找到只读文件
# find / -perm /u=r
Copy after login
14.找到可执行文件
# find / -perm /a=x
Copy after login
15.找到权限为777的文件并改为644
# find / -type f -perm 0777 -print -exec chmod 644 {} \;
Copy after login
16.找到权限为777的目录并改为755
# find / -type d -perm 777 -print -exec chmod 755 {} \;
Copy after login
17.找到指定的文件并删除
# find . -type f -name "linuxprobe.txt" -exec rm -f {} \;
Copy after login
18.找到指定类型的文件并删除
# find . -type f -name "*.txt" -exec rm -f {} \;
OR
# find . -type f -name "*.mp3" -exec rm -f {} \;
Copy after login
19.查找空文件
# find /tmp -type f -empty
Copy after login
20.查找空目录
# find /tmp -type d -empty
Copy after login
21.查找所有的隐藏文件
# find /tmp -type f -name ".*"
Copy after login
22.查找指定用户家目录下的指定文件
# find / -user root -name linuxprobe.txt
Copy after login
23.查找指定用户家目录下的所有文件
# find /home -user linuxprobe
Copy after login
24.查找指定组中的所有文件
# find /home -group developer
Copy after login
25.查找指定用户家目录下的指定文件并忽略大小写
# find /home -user linuxprobe -iname "*.txt"
Copy after login
26.查找最近50天修改过的文件
# find / -mtime 50
Copy after login
27.查找最近50天被访问过的文件
# find / -atime 50
Copy after login
28.查找最近50天到100天之间修改过的文件
# find / -mtime +50 –mtime -100
Copy after login
29.查找过去一小时内修改过的文件
# find / -cmin -60
Copy after login
30.查找过去一小时内修改过的文件
# find / -mmin -60
Copy after login
31.查找过去一小时内被访问过的文件
# find / -amin -60
Copy after login
32.查找大小为50M的文件
# find / -size 50M
Copy after login
33.查找文件大小在50M-100M之间的文件
# find / -size +50M -size -100M
Copy after login

本文原创地址:https://www.linuxprobe.com/linux-33-find.html作者:王毅,审核员:逄增宝

本文原创地址:https://www.linuxprobe.com/linux-33-find.html编辑:王毅,审核员:暂无

为您推荐一些与本文相关的文章:

  • swappiness的基本默认设置为60,加上生效这样便完成修改设置
  • 你不需要 Kubernetes?
  • 今天聊聊:每个 Linux 新手都应该知道的 四个命令
  • 《Windows核心编程第五版中文版》pdf版电子书免费下载
  • 物联网安全:可用性 or 数据
  • 谷歌将举办Pixel 3手机发布会
  • GNOME 正在(某种程度上)恢复在几年前删除的功能
  • 红帽Linux 6.8发布:支持更大XFS文件系统
  • 甲骨文推出全新 Java SE 定价模式
  • AI时代如何保护隐私?靠区块链还是靠法律

The above is the detailed content of Commonly used Find command examples under Linux: 33 cases. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template