If you need to find a certain directory on your Linux system, we’ve got just the guide for you. In this tutorial, we’ll be going through the step by step instructions to locate a folder on Linux via both the command line and GUI.
In this tutorial you will learn:
- Find a directory via command line
- Find a directory via GUI
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Find a directory via command line
Finding a directory or folder with the command line should work identically across any Linux distribution of your choice. All you need to do is open a terminal on your system and use the following find command syntax to see the location of a specified directory:
$ find /path/to/search -type d -name "name-of-directory"
Using that syntax, here’s how to search for a directory named “test” inside the home directory.
$ find $HOME -type d -name "test"
The -d
option is what causes find
to display directories (or folders) only. The -f
option can be used for files, or the options can be omitted entirely to find both directories and files with the specified name.
Use wildcards in your search if you’re only specifying part of the directory name, like so:
$ find $HOME -type d -name "test*"
Use the iname
option in place of name
if you’d like to perform a case insensitive search. Example:
$ find $HOME -type d -iname "test"
The find
command is probably going to be your best bet for finding a directory, but the locate
command deserves a brief mention as well. The find
command searches the file system in real time, whereas locate
has a database of the file/directory names and locations on a system.
This allows locate
to be a lot faster, but possibly less accurate as the database isn’t constantly refreshed. The find
command is also more flexible, offers more options, and is certain to be installed by default.
Find a directory with locate
command:
$ locate name-of-directory
Find a directory via GUI
To find a directory/folder with GUI, you can use your system’s file browser. We’ll show you what that looks like on our test system running the GNOME desktop environment, but your system may look different, depending on what desktop environment you’re running.
The instructions should be similar, as it can be assumed that any file browser you have will certainly offer a search function.
- Start by opening your file browser.
- Click the search icon to access the search bar, and type the directory you’re looking for in there. The file browser should then search for the folder and display its location.
Conclusion
Finding directories on Linux is simple. Between the find
and locate
commands as well as the built in file browser, there are a variety of good methods to quickly find a directory or folder in Linux.