Just installed a new Linux distro? You might wonder how to find files and directories on your new system.

There are a few different ways you can find files and directories on a Linux PC. You can use Linux commands via the terminal, such as find, to help you. Alternatively, you can use the built-in file management tool provided by your Linux distro.

Table of Contents

    If you want to find files and directories on Linux, follow the steps below.

    How to Find Files and Directories in Linux image 1

    Using the Find Command

    The find command is one of the most powerful and versatile tools for finding files and directories by name in Linux. It can search your folders for various criteria, such as the filename, owner, file permissions, file type, size, or date.

    Find can also perform actions on the matched files, such as deleting, moving, or executing commands on them. The basic syntax of the find command is:

    find [options] [path] [expression]

    Options controls how the command behaves, path specifies the starting directory or directories to search, while expression consists of additional options or actions that you can use (separated by operators).

    For example, to find all files with the .txt extension in the current directory and its subdirectories, you can use this command:

    find . -type f -name “*.txt”

    The dot (.) after find indicates the current directory. The -type f option specifies that you’re searching for regular files. The -name “*.txt” option matches files that end with .txt.

    How to Find Files and Directories in Linux image 2

    You can also use the -iname option instead of -name if you want to perform a case-insensitive search. For example:

    find . -type f -iname “*.txt”

    This will match files that end with .txt, .TXT, .Txt, etc.

    How to Find Files and Directories in Linux image 3

    The find command has a number of useful features and settings that you can explore by reading its manual page via the terminal (man find). Some of the most useful ones are:

    • -not: Negates the following expression. For example, -not -name “*.txt” matches files that don’t end with .txt.
    • -size: Matches files by size. For example, -size +1M matches files that are larger than 1 megabyte.
    • -mtime: Matches files by modification time. For example, –mtime -1 matches files that were modified within the last 24 hours.
    • -exec: Executes a command on each matched file. For example, -exec rm {} ; deletes each matched file.

    Using the Locate Command

    The locate command is another way to find files and directories in Linux. Locate is faster than the find command because it uses a previously built database of file names and locations. However, it may not be as up-to-date as the find command because the database is updated periodically by a cron job.

    The basic syntax of the locate command is:

    locate [options] pattern

    The pattern is a string of characters that you want to search for in the file names. The locate command will return all file names that contain the pattern as a substring.

    For example, to find all files that contain the word “yes” in their names, you can use this command: locate yes.

    How to Find Files and Directories in Linux image 4

    If you’ve recently updated a large number of files and you want to update the database manually before using the locate command, you can run this command via the terminal:

    sudo updatedb

    You may need to enter your password to run the command.

    How to Find Files and Directories in Linux image 5

    Like find, you can check for additional options for locate using the manual page via the terminal (man locate). These include:

    • -i: Ignores case when matching patterns. For example, -i linux matches Linux, LINUX, linux, etc.
    • -c: Counts the number of matching files instead of displaying them. For example, -c linux shows how many files contain linux in their names.
    • -l: Limits the number of matching files to a specified number. For example, -l 10 linux shows only the first 10 files that contain linux in their names.

    Using the GUI File Management App

    If you prefer a graphical interface for finding files and directories in Linux, you can use the file management app that’s included with your Linux distribution. This might be called Nautilus, Files, or File Manager, depending on whether you’re using Ubuntu or another Linux distribution.

    These apps allow you to browse and search your files and directories using a familiar window-based interface. You can navigate through your file system using the sidebar, toolbar, or breadcrumbs. You can also use keyboard shortcuts or drag-and-drop to perform various actions on your files and directories.

    To search for files and directories using the common file app, you can use the search box in the toolbar or press Ctrl+F. This will open a search panel where you can enter your search criteria.

    How to Find Files and Directories in Linux image 6

    You’ll also be able to filter the results by type, size, or date. In Files on Ubuntu, press the downwards arrow next to the search results to choose your search criteria.

    How to Find Files and Directories in Linux image 7

    Your file management app will display all of the matching files and directories in the main area. You can then double-click on any file or directory to open it or perform other actions on it using the right-click menu, as long as you have the necessary file permissions.

    Managing Files on Linux

    Finding files and directories in Linux can be a daunting task for beginners. By using the find and locate Linux commands, or by using your Linux system’s file management tool, you can search for files and directories by various criteria and perform actions on them. For instance, you can delete files on your Linux PC that you don’t need.

    Another task you could try is renaming your files and folders on Linux to make it easier to locate your most important files.