Security, PKI, sys and network admins

How to find files and folders on Linux

How to find files and folders on Linux

Ubuntu 18.04 LTS

Finding a directory or a file

In order to successfully find a directory/folder or a file in Ubuntu, you can easily use the find command.

Command syntax:

find /where-to-look -type d -name /what-to-look

Command explained:
    • -type

Using -type, helps us specify the type of search we’re executing: for a file or a directory?

      • d

Below, there is a practical command example where we search inside the /etc folder for a directory called data:
find /etc -type d data

How to find files and folders on Linux – Ubuntu 18.04: finding the "data" directory

How to find files and folders on Linux – Ubuntu 18.04: finding the “data” directory

      • f

As you might’ve guessed, the f letter stands for file which helps us do our search by file names. Below, we’re verifying the existence of the file called hosts, inside the /etc directory:
find /etc -type f hosts

How to find files and folders on Linux – Ubuntu 18.04: finding the “hosts” file

    • -name

Using -name we can easily specify our search term, a file or a directory.

Leave a Reply

Your email address will not be published. Required fields are marked *