How to search and find files from Linux Command Line

Here I am describing a simple command to locate files and folders from a Linux based server by using the file name. You can watch the video tutorial for this topic by clicking here.

Locate Command

This is the quickest way to find a file from a Linux server as the locate command is not searching through the file system for the name you are searching for. It is checking it in the 'mlocate.db' database file which contains all file paths in your system and which makes the check quicker.

We can simply install the locate command:

Centos Server: 

  # yum install mlocate

Ubuntu/Debian:

  # sudo apt-get install mlocate

Before using the command, we need to update the DB using the following command:

  # updatedb

Once it is done, you can simply use the command to find a file on the server by searching the file name:

eg: # locate my.cnf

The search is case sensitive.  Please see the examples shown in the next image:

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

cPanel: Apache-FastCGI Data Timeout Error

If you are using a cPanel server and have FastCGI enabled in Apache, you might be facing the...

Domainkey installer in cPanel

You can use the following cPanel script to install domainkey for an account...

Email issues :: Common Troubleshooting Steps

Here I will discuss some common errors and their solution: We are using a mail relay setup for...