Skip to main content

Unit 3 路 Linux^2 路 Lesson 27 of 34

Hide n' Seek

find

grep is great for finding text inside of files, but what if you don't even know where the file is? That's what find is for.

[user@linux]$ find [where to look] -name "[file name]"

For example:

[user@linux]$ find /home -name "flag.txt"

This looks through /home and every directory inside of it for anything named flag.txt.

Wildcards

If you only remember part of the name, you can use * as a wildcard (basically "anything can go here"):

[user@linux]$ find / -name "*.txt"

That finds every single .txt file on the whole system, starting from root. It's going to be a LOT, so maybe pipe it into head, or send the errors to /dev/null like we learned in Redirect Me.

[user@linux]$ find / -name "*.txt" 2> /dev/null | head

A few other flags worth knowing

FlagWhat it does
-type fOnly look for files
-type dOnly look for directories
-size +1MOnly files bigger than 1 megabyte

馃毄 CTF hint: Flags usually hide in really stupid, weird places. find is going to be your best friend.


Your turn

There's a secret.txt with the flag somewhere in ~/maze, hidden among a pile of fake secret.txt directories. Track down the real one.

Capture-the-flag challenge

Put the lesson to work on a challenge and submit the flag you find. Create a free account to do this part.

Do this lesson for real

With a free account you get the terminal, the challenges and the checks that go with every lesson in Intro to Linux, and your progress is saved as you go. CyberAcad is a 501(c)(3) nonprofit, so there is nothing to pay.