Need to know how to find a file in Linux Mint?
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux System queries.
In this context, we shall look into how to find files in Linux Mint system.
We have used Linux Mint 20.2 Cinnamon to show how files and directories can be located using different methods and commands.
The file manager of Cinnamon desktop environment is known as Nemo.
The developer of the project "nemo" Gwendal Le Bihan named it after Jules Verne's famous character Captain Nemo, who is the captain of the Nautilus. As the about section of Nemo says, it allows you to organize files and directories both on your local machine and online.
This interface is pretty much the same as of Window's file system. You can dive into any of the folders to access your files.
1. Locate
The quickest and simplest way to search for files and directories by their names is with the help of locate command.
This is the syntax of the command:
$ locate {filename}
Here is an example in which we tried to locate a file with the name resolv.conf in a specific directory. As you can see, the command returns all the files that have resolv.conf in their names in that directory:
Locate resolv.conf
To explore this command more and see all options that are available for locate, type man locate in your terminal.
2. Find
Find is a very important tool in Linux. It allows you to search files and directories and perform operations on them. It also lets you search by file, folder, name, creation date, modification date, owner and permissions.
Looking for a specific file?
If you want to find a particular file, the following command will look for it in current and sub-directories.
This is the syntax of the command:
$ find . -name {filename}
In the example, we have searched for a file with the name resolv.conf.
find . -name resolv.conf
The command returns with the file in the current directory.
3. Looking for files with a specific format?
If you want to see all files with a specific format in a particular directory, the following command will be used.
This is the syntax of the command:
$ find /home -name *.jpg
In this example, the command returns all the files that have the .PNG format in the specified directory:
find /home/linuxapt/Pictures -name *.png
4. Looking for empty files?
The following command returns all the files that are empty within the specified directory.
This is the syntax of the command:
$ find . -type f -empty
In the example, the command returns an empty file present in the specified directory:
find . -type f -empty
5. Use wildcards to look for files
This is the syntax of the command:
$ find . -name '*re'
In this example, the command returns with all the files with names ending with re:
Find . Name '*re'
6. Whereis
The whereis command is not everyday use command. It is used to locate the binary, source, and manual page files for a command. It is mostly used to find executables of an application, its manual pages, and configuration files.
This is the syntax of the command:
$ Whereis {applicationnname}
In this example, we have used flameshot application:
$ whereis flameshot
7. Grep
Grep is a Linux command-line utility that is used to find a string of characters in a specific line. When the match is found, it prints the line in the terminal window.
This is the syntax of the command:
$ grep {string} {file name}
In this example, the string you has been used and the filename is file.txt:
grep you file.txt.
Grep you file.txt
As visible, Whereis command returns all the lines that have the word you in them.
This article covers the commands (find, locate, whereis, grep) with the help of different examples to help you easily find files and directories in your Linux mint system. In fact, In Linux operating systems, the find command may be used to search for files and directories on your system. To search for files in a directory, the user invoking the find command needs to have read permissions on that directory.
The general syntax for the find command is as follows:
$ find [options] [path...] [expression]