locate Command in Linux: Fast File Search Using Database
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
That was just one piece. The course teaches the whole path — from your first command to exam day.