Mint

How to Find Files and Directories in Linux Mint 20

How to Find Files and Directories in Linux Mint 20

You have been trying so hard to locate a file on your new Linux system but after hours of rambling on the terminal, it is still missing. Now you are just sitting there wondering what a nut job Linux is. Trust me, I cannot agree with you more! Linux, at times, does feel like a puzzle where new users easily and often get lost. But do not worry, we are here to help you. Together, we will locate that mischievous little file of yours that is so good at hiding.

Let’s begin our hunt!

We have used Linux Mint 20.2 Cinnamon to show how files and directories can be located using different methods and commands.

How To Locate a File in Linux using File Manager

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.

Here we have the file system of Linux that looks pretty scary at first glance, but no need to worry, as you won’t have to deal with most of it. These are just folders with files which in case of need, can be easily located.

How To Find a File in Linux using Terminal Window

I know you are not a fan of Linux command line. Well, nobody is. And I am sorry to break it to you that you can never escape that black little window as long as you are going to work with Linux, no matter how much it spooks you. But no need to worry. It may seem tricky in the beginning but after learning a few commands you will be able to explore the whole file system easily.

Let’s start exploring!

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.

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.

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/azifa/Pictures -name *.png

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

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’

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

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.

In this document, we explored four commands (find, locate, whereis, grep) with the help of different examples to help you easily find files and directories in your linux mint system.

Similar Posts