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
- Find by name.
findtakes where to look, and then conditions. Quote a pattern with*, so that the shell doesn't expand it first. - Only folders.
-type dkeeps only folders, and-type fonly files. - Find what's big.
-size +100Mfinds files bigger than 100 MB. It's the first thing to run when a disk is full. - Find empty files.
-emptyfinds empty files and folders. They're often what's left after something failed. - Delete what you found.
-deleteremoves everything that matched. Run it without `-delete` first, and read the list. It also avoids theArgument list too longyou can get fromrmwith many files. - Find a config file. On Debian and Ubuntu, the default Nginx site is in
/etc/nginx/sites-available, with a link insites-enabled. On RHEL, Rocky and AlmaLinux there's nosites-available: the default Nginx site isconf.d/default.conf.