Linux Find File

Linux find file

Linux find file command explained. Finding files using the command line on a Linux machine could be very uncomfortable experience, especially for the beginners. Without a GUI it is very difficult to navigate through the directories and find the files you need. In this tutorial, we will show you how to find a specific file in Linux, using the command line.

The first thing your need to do is to connect to your Linux VPS via SSH. There are two common ways to search for a file under Linux. The one way is to use the find command and the other way is to use the locate command. Let’s start with the former.

1. Linux Find File Command

The Linux find file command allows you to search the directory tree using various search criteria such as name, type, ownership, size etc. This is the basic syntax:

# find path expression search-term

Here is a brief example on how to use the Linux find command to find a specific file by its name:

# find -name test.file

The command will search the entire directory tree for a file named test.file and will provide you with the location. You can try using a name of a file that actually exists on your Linux VPS.

Sometimes it may take few minutes for the find command to search the entire directory tree, especially if there are many files and directories on your system. To save a significant amount of time you can specify the searching directory. For example, if you know that the test.file is somewhere in the /var directory, there is no need to search other directories. Therefore, you can use the command below:

# find /var -name test.file

There is also an option to search for a file by time, size, ownership, permissions etc. For more information about these options, you can check the Linux find file command man page.

# man find

2. Locate File command

In order to be able to use the Linux locate command, you need to install it first.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer

Now just $43 .99


If you are using an Ubuntu VPS, run the following commands to install locate:

# apt-get update
# apt-get install mlocate

If you are using a CentOS VPS, run the following command to install locate:

# yum install mlocate

Locate is a faster option to find a file since it searches for the files in a database. To update the search databases run the following command:

# updatedb

To find files in Linux with locate, use the following syntax:

# locate test.file

Just like with the find command, there are many options to filter the search output. To learn more about this you can check the Linux locate command man page.

# man locate

Of course, you don’t have to use the Linux find file, if you use one of our Linux hosting services, in which case you can simply ask our expert Linux admins to look and find the files on Linux for you. They are available 24×7 and will take care of your request immediately. For more updates, you might want to consider reading Find Large Files in Linux.

PS. If you liked this post on how to use the Linux find file command, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment