How to find files in Ubuntu Linux with Locate and Find command?

Ubuntu Linux has a terminal to access the system without using the graphical interface. For this reason, it is advisable to learn to use the terminal and certain basic commands. If you want to search for files, you may be wondering how to search for files in Ubuntu Linux with Locate and Find command? , with this article you will learn how to do it.

How to find files in Ubuntu Linux with Locate and Find command?

Ubuntu Linux is an operating system created by the community and is free to use, that is, you do not have to pay to have the user license . You can use this system at home, an educational institution, or any business. Ubuntu Linux ensures the safety of its users through regular updates with server and desktop versions.

Next, we present relevant aspects about the Locate and Find commands and how you should use them in order to locate files from the Ubuntu Linux terminal.

What is the Ubuntu terminal?

The Ubuntu terminal is a command interpreter used to access the operating system through specific commands entered by the user. In this way, it is possible to perform different actions such as renaming files with the command line or searching for them quickly and efficiently.

Procedure to find files in Ubuntu Linux with Locate and Find command

If you have the Ubuntu Linux operating system and you want to search for files, you should learn to handle the Locate and Find commands as we explain in the following procedure.

What is the “Locate” command?

The “Locate” command is an essential resource for finding files because it is so fast and useful. “Locate” works by searching through the database file mlocate.db which contains all the file paths on the system.

To use the “Locate” command you must install it since it is not common to find it in the Ubuntu Linux system . Press the keys “Ctrl + Alt + T” and type sudo apt install locate in the terminal in order to proceed with the installation process of this resource.

Prepare the “Locate” command

In the same way that it is possible to install programs in Ubuntu Linux from the terminal, it is necessary to install “Locate” on the computer. To do this, go to the terminal again and type sudo updatedb. In this way, you will be able to update the database corresponding to the “Locate” resource.

Use the “Locate” command

To use the Locate command, go to the Ubuntu terminal with the “Ctrl + Alt + T” keys . There, type the command followed by the name of the file you want to find: locate filename.

Enter the manual to learn more about the Locate command

You can find more information about this command by typing the locate –h command in the terminal . With this line you will get relevant information that will help you make the most of this resource. Also, you can access the manual by typing: man locate.

What is the “Find” command?

The “Find” command is a more powerful search facility than “Locate” but slower. This occurs because “Find” searches your hard drive directly to find files and folders. Find is ideal when you want to find a file for which you cannot remember its precise name.

How does the Find command work to find files in Ubuntu?

The Find command searches for files that belong to a certain group of users , files that have been modified, hidden files, and files of a specific size.

Use the Find command to search for files in a specific directory

If you know the exact location of the file you want to find, then enter the terminal with the combination “Ctrl + Alt + T”. In the terminal, type the find command . –Name “* filename *” . The period (.) Refers to the “current directory”.

However, if you want to search the “home directory” you must replace the period (.) With (~ /) and if you are going to search the entire file system use (/).

Search for files on Ubuntu Linux with a specific size

If you want to get a file but only remember its size, you can type the find command . –Size -4M this line means that the resource will search for files less than 4 Mb in size.

 

Leave a Comment