跳转至

updatedb 与 locate 命令


2015-06-01 by dongnan

举个栗子

查找 tgt模块所使用的相关文件路径。

首先使用updatedb更新文件名称数据库

updatedb

# 根据文件数量、磁盘类型、配置等,花费时间可能很长。

然后使用locate查找相关文件路径

# 输入命令
locate tgt

/etc/tgt
/etc/rc.d/init.d/tgtd
/etc/rc.d/rc0.d/K35tgtd
/etc/rc.d/rc1.d/K35tgtd
/etc/rc.d/rc2.d/S39tgtd
/etc/rc.d/rc3.d/S39tgtd
/etc/rc.d/rc4.d/S39tgtd
/etc/rc.d/rc5.d/S39tgtd
/etc/rc.d/rc6.d/K35tgtd
/etc/selinux/targeted/modules/active/modules/tgtd.pp
/etc/sysconfig/tgtd
/etc/tgt/targets.conf
/lib/modules/2.6.32-431.el6.x86_64/kernel/drivers/scsi/scsi_tgt.ko
/usr/sbin/tgt-admin
#...省略
/usr/src/kernels/2.6.32-431.el6.x86_64/include/scsi/scsi_tgt_if.h
/var/lock/subsys/tgtd
/var/run/tgtd.ipc_abstract_namespace.0

命令帮助

updatedb

updatedb - update a file name database

This manual page documents the GNU version of updatedb, which updates file name databases used by GNU locate. 
The file name databases contain lists of files that were in particular directory tree when the databases were last updated.  
The file name of the default database is determined when locate and updatedb are configured and installed.

locate

locate - list files in databases that match a pattern

This manual page documents the GNU version of locate.  For each given pattern, 
locate searches one or more databases of file names and displays the file names that contain the pattern.  
Patterns can contain  shell-style metacharacters: `*', `?', and `[]'.



回到页面顶部