Linuxlab

Chapter 9

Finding files: find, locate, which

Updated July 3, 2026

Navigation lets you walk the tree, but it does not answer the question "where does the file I need live". For searching there are separate commands.

find: walking the tree

find walks a directory and everything inside it, selecting files by a condition. The general form is: where to search, then the condition, then what to do with what it found.

$ find . -name "*.log"        # files with the .log extension from the current directory down
$ find /etc -name "hosts"     # the file hosts somewhere in /etc
$ find . -iname "*.LOG"       # -i: case-insensitive

Put the name pattern in quotes. Otherwise the shell expands * itself, before find even runs, and the search breaks.

You can search by more than the na

Locked

The rest of this chapter is part of a paid course

You are reading the open part. Buy the course to read the whole chapter.

See the course