Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux updatedb Command

Linux updatedb Command

Linux Command Reference Linux Command Reference

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

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 Linux Command Reference