Monday 21 December 2015

Locate command in Linux

locate command search very quickly, because  locate does not search the files on disk rather it searches for file paths in a database. The locate database file is located at:

[root@localhost test]# locate mlocate.db
/usr/share/man/man5/mlocate.db.5.gz
/var/lib/mlocate/mlocate.db/var/lib/mlocate/mlocate.db.UY1Pjl
[root@localhost test]#


[root@localhost test]# locate sysctl.conf
/etc/sysctl.conf
/etc/sysctl.d/99-sysctl.conf
/usr/share/man/man5/sysctl.conf.5.gz
[root@localhost test]#

Now create a directory and touch a file

[root@localhost Desktop]# mkdir -p /root/test
[root@localhost Desktop]# touch /root/test/saidrasel.lst
[root@localhost test]# locate saidrasel*

Now execute the locate command to find "saidrasel.lst" file but could'nt get

[root@localhost test]# locate saidrasel.lst


Now execute the updatedb command,  it scans the whole system and updates the mlocate.db database file.

[root@localhost test]# updatedb
[root@localhost test]# locate saidrasel.lst
/root/test/saidrasel.lst
[root@localhost test]#

Note: So the limitation of the "locate" command is its dependency on the database which can be updated by another utility "updated". Hence, in order to get the latest and reliable results from "locate" command the database on which it works should be updated at regular intervals.

1 comment:

  1. Jadwal Daftar Sabung Ayam SV388 15 Februari 2019 di Situs Judi Sabung Ayam Online Melalui Agen Resmi Taruhan Sabung Ayam Live Asli Thailand.

    Jumat, Banten 15 Februari 2019 – Pada Hari Tersebut Akan Di Laksanakan Berbagai Pertandingan Sabung Ayam Secara Live di Arena Sabung Ayam Thailand.

    Untuk Info Lebih Lanjut Bisa Hub kami Di :
    wechat : bolavita
    line : cs_bolavita
    whatsapp : +628122222995
    BBM: BOLAVITA

    ReplyDelete