monovm

Follow MonoVM
on social networks
and stay updated
with our new posts.

instagram twitter linkedin Youtube facebook telegram
English
+370 5 205 5502 sales@monovm.com

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

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

09 Dec, 22 by Antoniy Yushkevych 7 min Read

List of content you will read in this article:

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

Mainly, CentOS is commonly used for providing a 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 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 forces together for better work.

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

  • It offers everything 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 meet 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 seamlessly, and move between various environments with community-maintained docker hub images. You can pull down any docker images frequently without any limitations.
  • It helps add value, extend, and modify 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.

Linux  VPS
Linux VPS

Starting From $5.99/Monthly

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 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 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, using the “locate” command in CentOS 8 server directly might cause some errors. This is because this command is generally not pre-installed or available by default on your system. In such a case, ensure 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, suppose we are done with the installation. In that case, 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, update the CentOS system's database using the below command.

sudo updatedb

(updated)

After the successful update of the database, you will get the success message on the screen. Now you are ready to use the locate command to find the 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 hesitation, as you already have installed the “mlocate” utility. So, run the following locate command along with the file name 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 you are trying to search for. Then the command will return the path to that file in the output shown below.

Method 2: Using the Linux find command for CentOS, Find files

Apart from 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, the CentOS find command already exists on the system, so there is no need to install any utility. You can use it directly without even needing to upgrade the CentOS database. To find any file, you can provide the file name and the find command with the “-name” parameter, as shown below.

find -name FileName

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

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

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. Many companies have used it for development and production environments. It has an interactive CLI, which is obvious due to the Linux kernel. You can run various commands using the command-line interface. One commonly used task is finding 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