linux使用find命令快速查找文件

有时候我们忘记文件存放在哪里了,我们只知道文件的名字或者名字的部分字节,可以使用find命令来快速查找:

 

# find / -name *node10*

/var/lib/libvirt/images/rh7_node10.img
 

这里我要找的是一个名字里面包含有node10字样的文件,很快就能找出它的位置了。

*代表通配符,-name代表按名字查找, /表示在根目录下查找。

 

如果记得完整的文件名字,也可以使用locate快速查找

[root@localhost ~]# locate main.cf
/etc/postfix/main.cf
/usr/libexec/postfix/main.cf
/usr/share/doc/postfix-2.10.1/main.cf.default
 

find也可以按类型查找

[root@localhost ~]# find /tmp/cluster/ -type d
[root@localhost ~]# find /tmp/cluster/ -type f

同时可以修改权限

find /tmp/cluster/ type d -exec chomod 755 { } \;

按照大小查找

[root@localhost ~]# find /boot/ -size +5M   查找大于5M的文件
/boot/initrd-plymouth.img
/boot/initramfs-0-rescue-e783146fd26f448d951f5c739b136d2f.img
/boot/initramfs-3.10.0-327.el7.x86_64.img
/boot/initramfs-3.10.0-327.el7.x86_64kdump.img
 

[root@localhost ~]# find /boot/ -mtime -5  查找5天内改动的文件
 

 

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值