描述:快速从系统数据库中查找指定的内容。python
用法:locate [option] [样式]linux
参数:正则表达式
-e 将排除在寻找的范围以外。数据库
-1 若是 是 1.则启动安全模式。在安全模式下,使用者不会看到权限没法看到 的档案。这会始速度减慢,由于 locate 必须至实际的档案系统中取得档案的 权限资料。安全
-f 将特定的档案系统排除在外,例如咱们没有到理要把 proc 档案系统中的档案 放在资料库中。python2.7
-q 安静模式,不会显示任何错误讯息。lua
-n 至多显示 n个输出。unix
-r 使用正规运算式 作寻找的条件。code
-o 指定资料库存的名称。io
-d 指定资料库的路径
-h 显示辅助讯息
-V 显示程式的版本讯息
示例:1.查找和pwd相关的全部文件
[root@share20 ~]# locate pwd /etc/.pwd.lock /usr/bin/pwd /usr/bin/pwdx /usr/include/pwd.h /usr/lib/modules/3.10.0-229.el7.x86_64/kernel/drivers/watchdog/hpwdt.ko /usr/lib/modules/3.10.0-327.4.5.el7.x86_64/kernel/drivers/watchdog/hpwdt.ko /usr/lib/x86_64-redhat-linux6E/include/pwd.h /usr/lib64/cracklib_dict.pwd /usr/lib64/python2.7/lib-dynload/spwdmodule.so /usr/sbin/unix_chkpwd /usr/share/cracklib/cracklib-small.pwd /usr/share/cracklib/pw_dict.pwd /usr/share/man/man1/pwd.1.gz /usr/share/man/man1/pwdx.1.gz /usr/share/man/man8/unix_chkpwd.8.gz /usr/share/nmap/nselib/unpwdb.lua /usr/share/nmap/nselib/data/psexec/pwdump.lua /usr/src/kernels/3.10.0-229.el7.x86_64/include/config/hpwdt /usr/src/kernels/3.10.0-229.el7.x86_64/include/config/hpwdt/nmi /usr/src/kernels/3.10.0-229.el7.x86_64/include/config/hpwdt/nmi/decoding.h
2.使用-r的参数能够使locate支持正则表达式
[root@share20 ~]# locate -r'\<passwd\>$' /etc/passwd /etc/pam.d/passwd /usr/bin/passwd