Looking for a specific directory in your Linux file system? Fortunately, you have many search tools at your disposal. We'll look at several easy-to-use options, and how to use them to search for folders efficiently.

Find a Folder in Linux

Many routine tasks in Linux, such as creating or editing a configuration file, will require you to locate particular folders.

While there are lots of easy methods for finding files, locating a directory is not as straightforward. A simple search with one of the common search tools may return only files, or flood your view with files that have similar names.

You can avoid those pitfalls, however, if you just tweak your search tool's options. So while you may have used the tools mentioned below already, you're going to learn today how to look only at folders and how to see the folders' sizes as well.

Search for a Folder in Linux Using GNOME Desktop

If you use the GNOME desktop, you can quickly find folders by opening the Files app and following these steps:

  • Navigate to the directory you want search inside of.
  • Click the Search button at the top of the Files window.
  • In the search bar's dropdown menu, select Folders in the What category, as shown below, and then select File Name.
Finding a Folder in Gnome Files App

You can now search the directory for any sub-directories with names matching your search term.

Search for a Folder in Linux With Catfish

If you don't use GNOME, another popular and widely-available GUI method for searching directories in Linux is Catfish. You can install the app on Ubuntu-based systems either by searching your software manager for it, or by issuing with this command:

        sudo apt install catfish
    

To install Catfish on Fedora and other RPM-based systems, use this command:

        yum install catfish
    

Once it's installed, open Catfish and make sure the left-hand sidebar is visible. If it isn't, press F9, or click the gear icon in the top-right of the window and check the Show sidebar option.

By default, Catfish will try to search for files, not folders. You'll need to specify you're looking for a folder by checking the Folders box, leaving all the other options unchecked.

Searching for Directories with Catfish App

Find a Folder By Name

If you're willing to use the terminal, the find command is a search tool that's both simple and versatile. Here's an example of its usage:

        find ~/Documents -type d -name MyFolder
    

The above command will search the entire file system (specified by ~/Documents) for directories (type -d) that are named exactly MyFolder (-name MyFolder).

If you want to search the root file system, you'll need to give / as the location. Additionally, you'll need to elevate privileges by adding sudo to the front of it..

Instead of specifying a location, you can also simply change your current directory to the folder you want to search, in which case find will only search the current directory.

Searching for Folders with Linux Find Command

The type -d part of the command specifies that it's a directory you're looking for, instead of a file. Be sure to include that when you search so that you aren't overwhelmed with file names that happen to contain the same search term.

If you're not sure if the folder you're looking for uses upper or lower case in its name, you can change the -name argument to -iname to force a case-insensitive search.

In addition, you can use a wildcard tag if you're only sure of part of the folder's name.

Here's an example using both of those options:

        find / -type d -iname myfolder*
    

Find a Linux Folder By Exact Name

A similar tool you might have used before is locate. A search for a folder with locate will look like this:

        locate -b '\MyFolder'
    

The above command will find any folder in your file system named exactly "MyFolder".

To look for partial matches, remove the quotes or insert an asterisk. Be warned, however, that a wildcard search is likely to bring up matching file names in addition to folders.

You can also pass the -i option to ignore case.

Searching for Directories with Linux Locate Command

At this point, you might be asking, what's the difference between locate and find?

Short answer: Locate is faster, but find is more accurate.

The find command looks through your live file system for your search term to return paths exactly as they currently exist.

Locate, instead of searching the live file system, searches a pre-indexed database of all your file and folder names. The simplified approach makes for much faster searching, but that database can be out-of-date.

Related: 7 Great Apps to View Disk Usage in Linux

Thus, locate is the best option as long as you don't think the folder was created or moved very recently.

If you do think your folder's been modified recently, you should use find. Or, you can use locate if you issue this command first to update the search database:

        sudo updatedb
    

The operation will take time, but once it's finished, you can be certain your locate commands return quick and accurate results.

Find The Size Of a Linux Directory

If you've found a folder with one of the above methods and you now want to see its size, you can do that quickly with the du command. Specify the options -hs followed by the path to your folder, like this:

        du -hs /MyFolder
    

Remove the s character (for summary) to see the size of each sub-directory as well.

Find Folders Fast in Linux

Any folder you seek is now at your fingertips with a few quick clicks or commands.

If you need to move the contents of your folders to another PC, you might be surprised at the options you have for wirelessly transferring your folders.