fbpx locate Command on Linux: Find Files Fast | Certificação Linux

locate Command in Linux: Fast File Search Using Database

📅 01/01/2019 ⏱ 1 min ✍️ Uira Ribeiro
Linuxcommands
locate Command in Linux: Fast File Search Using Database
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

The locate command can be used to find files on the system through a database it maintains. Because it searches in a database, the result is instant. However, recently added files may not be in the database yet.

This way, the database can be updated from time to time, or manually.

Example:

$ locate passwd/etc/passwd/etc/passwd-/etc/pam.d/passwd/etc/security/opasswd/usr/bin/gpasswd( ... )

To update the database, the updatedb command must be executed as root:

$ sudo updatedb

The locate command is not always installed by default in distributions, which can be done with apt or yum commands, depending on the distribution:

For Debian or Ubuntu distributions:

$ sudo apt install locate

For Red Hat/CentOS/Fedora:

$ sudo yum install locate

Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.

Learned something? Share it

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp