linux常用命令
find查找
find 查找范围 匹配条件(范围要尽量小,这样查找起来才快)
#匹配条件:
- -name: 按照文件的名称
- -type: 文件类型(l,d,f)
- -size: 文件大小 +(大于)/ -(小于) K M G
- -mtime: 文件修改时间 +(超过)/ -(低于)指定时间
- -perm: 根据权限
查找/etc下所有以 .conf结尾的文件
[root@lamp ~]# find /etc -name *.conf/etc/libreport/events.d/collect_dnf.conf /etc/vconsole.conf /etc/nsswitch.conf /etc/e2scrub.conf /etc/sysconfig/nftables.conf......查找大于10M的文件
[root@lamp ~]# find /etc -size +10M/etc/udev/hwdb.bin查找权限为 rwxr-xr-x 的文件
[root@lamp ~]# find /etc -perm 755/etc /etc/libreport /etc/libreport/workflows.d /etc/libreport/events.d /etc/libreport/plugins /etc/libreport/events /etc/xml /etc/gdbinit.d......处理动作:在找到匹配的文件之后,对这些文件执行命令
find指定路径 匹配条件-exec命令{}\;在找出大于60M的文件后,显示出其详细信息
[root@lamp ~]# find /boot -type f -size +60M -exec ls -lh {} \;-rw-------.1root root 75M3月1422:17 /boot/initramfs-0-rescue-959db6823cff41b687677128386b2c8e.img