Using mlocate to search on multiple systems in parallel
When you need to search for files or directories on your computer, it can be a time-consuming process, especially if you have a large amount of data. Luckily, there are tools available that can help speed up this process by searching your entire system in a matter of seconds. One such tool is mlocate.
mlocate is a command-line utility that uses an indexed database to quickly locate files and directories on a Linux system. It works by periodically updating its database, which contains the names and locations of all files and directories on your system. When you perform a search using mlocate, it looks up the database instead of searching the entire filesystem, resulting in much faster search times.
Installing mlocate
Before you can start using mlocate, you need to make sure it is installed on your system. To install mlocate, open a terminal and run the following command:
sudo apt-get install mlocate
This command will install mlocate and its dependencies on your system. Once the installation is complete, you can start using mlocate to search for files and directories.
Performing a basic search
To perform a basic search using mlocate, open a terminal and use the following command:
mlocate <search term>
Replace <search term> with the name or part of the name of the file or directory you are looking for. For example, if you are looking for a file called "document.txt", you can run the following command:
mlocate document.txt
mlocate will search its database and display a list of all files and directories that match your search term. The search is not case-sensitive, so you don't need to worry about uppercase or lowercase letters.
Searching on multiple systems in parallel
By default, mlocate only searches the local system. However, if you have multiple systems that are connected to each other, you can configure mlocate to search on all of them in parallel. This can be useful in situations where you need to search for a file or directory that may be located on a different system.
To enable parallel searching, you need to edit the mlocate configuration file. Open a terminal and run the following command:
sudo nano /etc/updatedb.conf
This command will open the mlocate configuration file in the nano text editor. Look for the line that starts with "PRUNE_BIND_MOUNTS" and add a hash symbol (#) at the beginning of the line to comment it out. Then, look for the line that starts with "PRUNEFS" and add a hash symbol (#) at the beginning of that line as well.
Save the changes and exit the text editor. Now, when you perform a search using mlocate, it will search on all connected systems in parallel.
Updating the mlocate database
The mlocate database is automatically updated on a regular basis, but there may be times when you want to manually update it. To update the mlocate database, open a terminal and run the following command:
sudo updatedb
This command will update the mlocate database, ensuring that it contains the most up-to-date information about your files and directories.
Conclusion
mlocate is a powerful tool that can greatly speed up your file and directory searches on Linux systems. By using its indexed database, you can quickly locate any file or directory on your system. And by configuring mlocate to search on multiple systems in parallel, you can extend its functionality to search across connected systems as well.
| Source | Link |
|---|---|
| mlocate man page | https://linux.die.net/man/1/mlocate |
| mlocate GitHub repository | https://github.com/jonas/tig |