본문 바로가기
WEB/Linux

Difference between find and locate

by Zayne 2024. 1. 29.

I wondered when I learned find and locate commands from the last lesson.

I've got the answer today.

 

locate uses a prebuilt databse, which should be regularly updated,

while find iterates over a filesystem to locate files.

Thus, locate is much faster than find, but can be inaccurate if the db is not updated.

 

To update locate db run updatedb

 

Here's an example:

 

for running updatedb, you need to become root.

 

When I created a new file, I could search it using find command.

On the other hand, locate wasn't working.

It's faster than find command but like you can see, It uses a prebuilt db.

'WEB > Linux' 카테고리의 다른 글

Soft and Hard links  (0) 2024.01.30
Wildcards  (0) 2024.01.29
명령어(find, locate)  (0) 2024.01.28
명령어(touch, cp, vi, mkdir)  (1) 2024.01.28
Linux File Properties  (0) 2024.01.27