+370 5 205 5502 sales@monovm.com

How to Find a File in CentOS? [Centos Find File]

This Linux tutorial will show you how to find a file in CentOS. Read on to find out. How to Find a File in CentOS [Search File In CentOS]

07 Jan, 22 by Antoniy Yushkevych 7 min Read

List of content you will read in this article:

Do you want to understand the concept of centos find file or centos search file command. Before jumping into the topics, we should understand the concept of Linux and market about it. Linux has various distributions available in the market and one of them is CentOS. CentOS stands for community enterprise operating system. In 2004, CentOS was released as a free operating system distribution that is based on the Linux kernel. It is completely derived from the RedHat Enterprise Linux (RHEL). 

Mainly, CentOS is commonly used for providing the free enterprise-class computing platform and helps in maintaining 100 percent compatibility with its upstream source RedHat. You won’t believe that in 2010, CentOS left behind Debian and became the most widely used Linux distribution. It has supported more than 30 percent of the web servers. But in 2012, Debian again took over CentOS.

How to Find a File in CentOS [Search File In CentOS]

In 2014, CentOS and RedHat joined their forces together for better work.

Below are some reasons that you should use CentOS as your operating system.

  • It offers everything that your team will expect from an operating system that will work perfectly for the modern business.
  • Every Linux deployment is cost-effective and moving from RHEL to CentOS will be safe and save more than 30 percent of your cost.
  • CentOS provides straightforward installation and helps in meeting all your enterprise provisioning requirements whether your system is scaling up or down.
  • You can easily upgrade the production without facing any downtime as it offers seamless up-gradation even for the major versions available.
  • It allows you to sign up, update, and move between various environments seamlessly with community-maintained docker hub images. You can pull down any docker images frequently without any limitations.
  • It helps in adding value, extending, and modifying whatever you want, whenever you want, and for any reason. There will be no vendor lock-in situation.
  • You can make any changes without going outside of the license boundaries.
  • It provides open-source support for managing issues.

Like other operating systems, CentOS also has various files residing on the system. It allows you to find files with GUI-based methods. It offers a command-line tool where you can run various commands to search for a particular file. CentOS offers two simple and straightforward methods of finding the files.

In order to find files residing on CentOS, you can use the below-listed two methods. These are the commonly used command-line interface commands. Locating a particular file or a group of files with the common attributes like the same extension, for example. CentOS offers the command "find" that helps in efficiently looking for files present on your hard drive.

Method 1: Find Files in CentOS with the help of the “locate” Command

Locate is the command that is generally used to find a specific file that has been stored on the system anywhere. With this command, you can just run a simple command and you will get the desired output. It consists of two simple steps that are mentioned below.

Step 1: start with installing the “mlocate” Utility in CentOS 8:

Sometimes, the use of the “locate” command in CentOS 8 directly might cause some errors to occur. This is because this command is generally not pre-installed or available by default on your system. In such a case, make sure that you install the utility containing the “locate” command. That utility is called the “mlocate” utility. You can install this utility using the below-mentioned command on the command line.

sudo dnf install mlocate

So make sure to install it beforehand to avoid any type of error. Now if we are done with the installation, we can proceed with the next step of updating the CentOS system’s database to be updated and avoid compatibility issues for the command.

Step 2: Updating the CentOS 8 System’s Database:

Whenever you install any new utility make sure that you update the database of the CentOS system using the below command.

sudo updatedb


After the successful updation of the database, you will get the success message on the screen. Now you are ready to use the locate command for finding the specific file from the system.

Step # 3: Finding the Desired File with the help of the “locate” Command in CentOS 8:

Now run the locate command without any hesitation as you already have the “mlocate” utility installed. So, run the following locate command along with the provided file name that you want to search.

locate FileName

Now, you can replace the filename parameter in the above command with the name of the file that you want to find from the system. Here, we are considering TestFile.txt for searching. You can run the following command for this.

If the file already exists on the system that you are trying to search, then the command will return the path to that file in the output as shown below.

Method 2: Using the Linux find command for Centos Find files

Apart from using the locate command, you can also use the centos find command for the same purpose. It also allows you to find the file on the CentOS system.

Unlike locate command, centos find command already exists on the system so there is no need to install any utility for it. You can use it directly without even the need to upgrade the database of CentOS. In order to find any file, you can provide the file name along with the find command with the “-name” parameter as shown below.

find -name FileName

You can replace the filename with the specified file that you are looking for in the system. Here we are using the TestFile.txt. 

If the specified file exists on the system, the above-mentioned command will provide the path of that file as its output. You can see that the output contains “./” before the file name, it means that the file is stored at the home directory of the system. 

Here, we have mentioned two basic commands (locate and find) for finding a file on the CentOS system i.e. used for centos find file, centos search file, and centos find file by name. Also, CentOS is a community enterprise OS and is available as a stable, predictable, and robust Linux distribution. It has been used by many companies for development and production environments. It comes with an interactive CLI, which is obvious due to the Linux kernel. You can run various commands using the command-line interface. One of the commonly used tasks is to find a specific file on the system.

People are also reading:

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com