Linux updatedb Command
The updatedb command is used to create or update the database files required by the slocate/locate command.
The updatedb command takes a relatively long time to run because it traverses the entire system directory tree and writes all file information into the slocate/locate database file.
**Note:** slocate itself has a database that stores information about files and directories on the system.
Syntax
updatedb(选项)
Parameters
- -o
: ignore the default database file and use the specified slocate database file; - -U
: update the slocate database for the specified directory; - -v: display the detailed execution process.
The following example checks for a non-existent file runoob.txt:
# locate runoob.txt # 检索 runoob.txt,没有任何输出,表示没有该文件
# touch ./runoob.txt # Add file runoob.txt
# locate runoob.txt # search for runoob.txt again, still no such file
# update locate.db database
# locate runoob.txt # search database again for runoob.txt, find the file
/root/runoob/runoob.txt
Use -U the option can specify the directory whose slocate database to update.
updatedb -U /root/runoob/
Linux Command Reference