Skip to content
ohsudo, Home

Module 2: Text and logs

Find files with find

Where did that config go? What's filling the disk? find walks a folder tree and checks each file against the conditions you give it.

● Runs 100% in your browser. Nothing here can harm a real system.

Step 1 of 6

Find by name

find takes where to look, and then conditions. Quote a pattern with *, so that the shell doesn't expand it first.

Your task

Find every file ending in .log under data.

guest@ohsudo: ~ — Ubuntu 24.04

Starting the terminal…

What you'll practice

  1. Find by name. find takes where to look, and then conditions. Quote a pattern with *, so that the shell doesn't expand it first.
  2. Only folders. -type d keeps only folders, and -type f only files.
  3. Find what's big. -size +100M finds files bigger than 100 MB. It's the first thing to run when a disk is full.
  4. Find empty files. -empty finds empty files and folders. They're often what's left after something failed.
  5. Delete what you found. -delete removes everything that matched. Run it without `-delete` first, and read the list. It also avoids the Argument list too long you can get from rm with many files.
  6. Find a config file. On Debian and Ubuntu, the default Nginx site is in /etc/nginx/sites-available, with a link in sites-enabled. On RHEL, Rocky and AlmaLinux there's no sites-available: the default Nginx site is conf.d/default.conf.

See also