To find a directory by name on Linux, start with find /path -type d -name "directory_name"; use -iname for case-insensitive matching. Replace /path with the smallest sensible starting point, add 2>/dev/null when permission warnings are noise, and use find /path -type f when you are searching for files rather than folders.
How to Find a Directory on Linux: 5 Easy Commands
Lost a folder? Learn how to find a directory on Linux using find, locate, and grep commands. Simple examples for Ubuntu, CentOS, and Arch.
// The short answer
In this guide · 6 sections
We’ve all been there: you know for a fact you created that project folder or unpacked that archive, but now it feels like it just vanished into the Linux filesystem. When you don't have a desktop UI to click through - or when clicking around just wastes time - the command line gives you a handful of straightforward tools that track down what you need right away. Whether you're sorting out a remote server or just trying to get back to work on your own machine, getting comfortable with these few commands will save you a ton of headaches down the road.
Quick Answer: If you just need the command to copy and paste right now, this is the pattern you'll use most often. Adding the type d flag makes sure Linux only hunts for directories, keeping standard files out of your way. (If it turns out you actually need a single file rather than a directory, finding files in Linux works slightly differently, but the logic is pretty much identical.)
Bash
find /path -type d -name "foldername"Using the find Command (The Most Reliable Tool)
Whenever people talk about hunting down things in Linux, find is usually the first tool they reach for. What makes it so handy is that it traverses your filesystem in real time, so if you made a directory thirty seconds ago, find will spot it immediately. The slight tradeoff is that since it walks your storage drive folder by folder, a full-system search across a massive disk can take a moment compared to an indexed tool.
The Basic Search by Name
To get started, you just tell find where to begin searching and what name to match. If you have no idea where a folder might be hiding, you can start from root (/) or narrow it down to your own home directory (~) so you don't waste time scanning system binaries.
Bash
find /home/user -name "downloads"Running that will look through everything under /home/user for anything labeled "downloads." Keep in mind, without extra flags, it spits out both files and folders that share that name, which can get noisy pretty fast.
Limiting the Search to Folders Only
If you know you're looking for an actual directory, you’ll definitely want to strip out regular files from the results. Throwing in the -type d argument takes care of that instantly. It’s a huge help when you have things like a config folder sitting alongside a generic config text file.
Bash
find . -type d -name "config"This tells the shell to check your current folder (that's the .) along with every subfolder inside it, bringing back only the directories named "config."
Ignoring Capital Letters
One little detail that trips people up is that Linux treats uppercase and lowercase letters as completely separate things - so Backup and backup aren't seen as the same path. When you can't recall whether you capitalized something when you made it, swap out -name for -iname.
Bash
find /var -type d -iname "log"With -iname, it catches log, Log, LOG, or any weird variation you might have typed without realizing it.
Dealing with "Permission Denied" Noise
Whenever you run a broad search starting from the root folder (/), your terminal will probably throw a bunch of "Permission denied" errors for system folders your regular user account isn't allowed to poke into. Having dozens of those lines scroll by can easily drown out the one path you actually care about.
You can handle that in two straightforward ways. If you have admin rights and genuinely need to inspect restricted areas, just slap sudo in front of the command to give yourself full access across the entire tree.
Bash
sudo find / -type d -name "secret_folder"If you don't have root privileges or you just want a clean screen without the fuss, you can tell the shell to pipe standard error right into /dev/null, which quietly throws all those permission warnings in the trash.
Bash
find / -type d -name "ssh" 2>/dev/nullThat keeps your terminal neat and readable, printing only the directories your current account actually has permission to view.
Using locate (The Speed Demon)
If you're in a hurry and searching for a folder that has been sitting around on your system for a while, locate will beat find on speed every single time. Instead of crawling across physical storage block by block, it looks through a lightweight, pre-indexed database (mlocate.db) behind the scenes.
Depending on your distribution, it might not come installed out of the box, but grabbing it through your regular package manager only takes a few seconds.
Bash
sudo apt install mlocateThe only catch with locate is that because it reads an index, it won't see a directory you set up just a couple of minutes ago. You can easily get around that by telling the system to refresh its database right before you run your search.
Bash
sudo updatedb
locate -b "\MyFolder"Adding that -b switch tells locate to look only at the very end of the path (the basename), keeping it from matching every single nested path that happens to have your search term tucked inside it.
Searching by Modification Time
There will be days when the exact name of a folder completely slips your mind, but you know you were messing around with it earlier in the afternoon. In situations like that, you can lean on timestamps instead of names to narrow things down.
If you want to see all directories touched over the past day, you'd run:
Bash
find . -type d -mtime -1This is a lifesaver when you're debugging or testing software. For instance, if an installer dropped some new folders somewhere unexpected and didn't tell you where, running a quick time-based check will show you exactly what popped up.
Once you surface those forgotten directories, you'll often discover a bunch of leftover temp folders or outdated backups taking up room. If you spot anything you don't need anymore, you can go ahead and remove the directory properly to keep your drive from getting cluttered.
Tracking Down Program Paths
Sometimes the directory you're actually hunting for belongs to an installed tool or daemon rather than a personal project. When that's the goal, generic filesystem searches are overkill - tools like which and whereis get straight to the point.
Bash
which python3That will spit out the direct path to the binary itself. If you also want to see where its manual pages, config files, and system folders live, whereis gives you the broader picture:
Bash
whereis nginxIn a single line, it hands you the executable path, the main configuration directory, and where the docs are stored.
The Desktop Route (If You're Not in the Terminal)
If you happen to be running a Linux desktop setup like GNOME, KDE, or XFCE, you don't necessarily have to pop open a shell every time you want to find a folder.
- GNOME (standard on Ubuntu): Just tap the Super (Windows) key and start typing what you're looking for; the system search brings up matching folders and settings right away.
- KDE Plasma (Dolphin): In Dolphin, pressing
Ctrl + Fpulls up a handy filter bar at the top, letting you search specifically for folders without touching the command line.
Behind the scenes, these desktop tools rely on local indexers (like Tracker or Baloo) to keep searches quick, giving you the same kind of convenience without having to memorize flags.
Quick answers
Frequently asked questions
How do I find a specific directory in Linux?
To find a specific directory, use the command find / -type d -name "directoryname". This command scans your file system starting from the root directory and filters the results to show only folders, excluding standard files.
How do I list all directories in the current folder?
You can list only the directories in your current location by running ls -d */. This filters out regular files from the output, giving you a clean list of subfolders immediately available to you.
How do I search for a folder if I don't know the exact name?
Use wildcards with the find command, such as find . -type d -name "*partialname*". The asterisks act as placeholders for unknown characters, allowing you to locate any folder that contains that specific phrase in its name.
Why does the find command say "Permission denied"?
This error occurs because the command is trying to access system directories that your current user account does not have permission to view. To fix this, run the command with sudo or add 2>/dev/null at the end to automatically hide these error messages.
What is the difference between locate and find commands?
find searches the live file system in real-time, which is slower but always accurate, while locate searches a pre-built database for instant results. Because locate relies on a database, it may not find files created very recently unless you run sudo updatedb first.
How can I find a directory that was recently modified?
You can find directories modified within the last 24 hours by using find . -type d -mtime -1. This is particularly useful for troubleshooting or finding where a recent installation placed its configuration files.
How do I find hidden directories in Linux?
Run the command find . -type d -name ".*" to specifically search for directories that start with a dot. Hidden directories usually store user configurations and are invisible to standard listing commands unless specifically targeted.
Can I find a directory by its size in Linux?
Yes, you can search for directories based on their content size, for example, find . -type d -size +100M. However, note that find checks the size of the directory file itself (usually 4KB), so for disk usage analysis, the du -h command is often a better tool.
Something wrong or out of date?
Tools change fast. Tell the editor what no longer works.