Linux updatedb Command
The updatedb command is used to create or update the database files required by the slocate/locate command.
The execution process of the updatedb command is relatively long, because during execution it traverses the directory tree of the entire system and writes all file information into the slocate/locate database file.
Note:slocate itself has a database that stores information about files and directories in the system.
Syntax
updatedb(选项)
Parameters
- -o<file>: Ignore the default database file and use the specified slocate database file;
- -U<directory>: Update the slocate database for the specified directory;
- -v: Display the detailed execution process.
The following example checks for a non-existent file example.txt:
# locate example.txt # 检索 example.txt,没有任何输出,表示没有该文件 # touch ./example.txt # 添加文件 example.txt # locate example.txt # 再次检索 example.txt,依然没有该文件 # updatedb # 更新 locate.db 数据库 # locate example.txt # 再次数据库检索 example.txt,找到该文件 /root/example/example.txt
Use-UThe option can specify the directory for which to update the slocate database.
updatedb -U /root/example/Other Extensions
Linux Command Reference