How to find folders in Linux

By

To find files on Linux, most people use a graphical manager of files such as  Dolphin on KDE, Nautilus on Gnome, and Thunar on Xfce. Regardless of which desktop manager you use, there are many ways to use the command line to locate files in Linux.

In this article, we will see different approaches for finding files in Linux.

Using the Find Command

‘find’ command is used for looking up the files. You have to use file names with the syntax. In the simplest way, you can search in the present working directory or in other ones. The search result will show you some output after applying the searching criteria to the file names. You can also search for files based on their type, permissions, owner, filename or any other specification supported by the file command. Write out the following command in the terminal, it will let you list all of the files present in the current working directory.

$ find .

Point the -name argument to locate files that fit a given pattern. Metacharacters such as * can be added in file naming. You have to use ‘\’ in front of each of these characters otherwise you have to place them in quotations.

For example, you want to see a list of the documents or files that have the letters ‘pro’ in their file name.

For that, avail this variation of file command.

$ find . -name pro\*

Another thing you should know about the find command is that it is case-sensitive. With the combination of file command and -iname option, you can create a query for searching a case-sensitive expression or word.

The find command provides a  lot of choices for narrowing down your search. To know more about find commands and its use, execute ‘man find’ in the terminal.

$ man find

Using the Locate Command

The locate command is speedy as compared to find command. It is faster because  for searching it utilizes a created database.Meanwhile it looks for the file in other directories and also in the whole system. This command results in a path names list that has the searched word in them.

$ locate bluetooth

Using the Which Command

The command “which” returns the executable’s absolute path that is called when a command is given. This is useful for locating an executable so that you can create a shortcut to it on the desktop, a monitor, or another place in the desktop manager.

Write-out a command that displays firefox. By default, only the first matching executable is shown with that instruction. -a option will retrieve a whole list of matching executables.

$ sudo which -a firefox

Using the Whereis Command

The whereis command is utilized for finding out the page files for man, source, and binary file types. Write-out ‘whereis firefox’ on the terminal and it will show you the given output.

$ whereis firefox

Conclusion:

We have seen different commands for finding files such as find command, Locate, which, and whereis commands.

Subscribe to Our Newsletter
Join our Newsletter and get the latest Linux news and tips
in your inbox for FREE.