Finding Files

Learn how to find files in a directory using the CLI.

Sometimes, we don’t know where to look for a file. Maybe we’ve misplaced it, or maybe we’re the type to save everything we’ve ever done and have lost track of the file several months ago. GUI interfaces usually have some tool that can search through our disk and find files. A tool on the CLI does that too, and it’s the appropriately named find command.

The find command

We can locate files by name, last modified date, or even by the content they contain with find.

In Creating and Reading Files, we created a file named greetings.txt in the root directory. Let’s use the find command to look for that file in the root folder:

$ find / -name "greetings.txt"

Get hands-on with 1400+ tech skills courses.