一 简介
1、语法
locate 文件名
在后台数据库中按文件名搜索,搜索速度更快。
2、locate命令搜索的后台数据库
/var/lib/mlocate
该数据库默认是一天一更新。
3、强制更新数据库
updatedb
4、优点
快
5、缺点
只能按照文件名搜索
二 实战
[[email protected] test]# lsabc abc.soft[[email protected] test]# updatedb[[email protected] test]# locate abc.soft/root/test/abc.soft[[email protected] test]# touch abcdef[[email protected] test]# locate abcdef[[email protected] test]# updatedb[[email protected] test]# locate abcdef/root/test/abcdef[[email protected] test]# locate mlocate/etc/cron.daily/mlocate/usr/share/doc/mlocate-0.26- ......
/var/lib/mlocate/var/lib/mlocate/mlocate.db/var/lib/mlocate/mlocate.db.FhTi2M
三 /etc/updatedb.conf配置文件
lolate whereis which 都遵循此规则。
四 实战
[[email protected] test]# touch /tmp/cakin2425[[email protected] test]# updatedb[[email protected] test]# locate cakin2425[[email protected] test]# cat /etc/updatedb.confPRUNE_BIND_MOUNTS ="yes"PRUNEFS ="9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset debugfs devpts ecryptfs exofs fuse fuse.sshfs fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs sockfs sysfs tmpfs ubifs udf usbfs"PRUNENAMES =".git .hg .svn"PRUNEPATHS ="/afs /media /mnt /net /sfs /tmp /udev /var/cache/ccache /var/lib/yum/yumdb /var/spool/cups /var/spool/squid /var/tmp"