linux之find命令的详细介绍

find常用参数

1.find 命令

参数 作用
-name 查找
-user 文件拥有者
-group 根据文件拥有组
-type 类型
-perm 文件权限
-exec 执行
-maxdepth 最大深度
-mindepth 最小深度
-o 或者
-a 并且
-not 反选

2.练习:

  • 查找最大深度与最小深度
    在这里插入图片描述
  • 建立一些文件,修改所有人和所有组
    在这里插入图片描述
  • 用户组
    在这里插入图片描述
  • 结合-o -a -not 使用
    在这里插入图片描述
  • find /mnt -perm
find /mnt -perm 111 文件权限为111
find /mnt -perm -111(-表示并且) 文件权限u位有1 G位有1 o位有1
find /mnt -perm /111(/表示或者) 文件案权限u或G或O 含有1

在这里插入图片描述
理解:111是3个条件,211也是3个条件,311则是4个条件(因为3=2+1,参考1248),755是7个条件(7=1+2+4;5=1+4)对应下来就是3个+2个+2个=7个条件

  • find /mnt -perm /111 -type f -exec chmod ugo-x {} ;
    注意:要加";"
[root@rhel8 mnt]# find /mnt -perm -111 -type f -exec chmod ugo-x{} ;		
find: missing argument to `-exec'
[root@rhel8 mnt]# find /mnt -perm -111 -type f -exec chmod ugo-x{} \;
{} 表示find命令查找结果 #\是为了转译“;”
  • 查看/分区中大于100M的文件
    在这里插入图片描述
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章