Introduction¶
Welcome to the Unix Scavenger Hunt! This activity is designed to help you explore and become more comfortable with Unix commands. Each prompt is a mini adventure where you’ll use the terminal to accomplish specific tasks. Feel free to try the challenge in any order!
Rules¶
- You can use Google and other resources to find the commands and solutions, but try using
man
and-h
first to see if the documentation makes sense! - Make sure to write down/document the commands you use and what those commands do. We will go around and share what we learned at the end of the class time.
- Try to stick to terminal - don’t use your machine’s GUI to get to the solutions!
- Have fun and enjoy the exploration!
Scavenger Hunt Challenges¶
We are sharing a folder with all of you via Slack. Everyone should download a copy of this folder onto their machine for this exercise.
Challenge 1: The Hidden Treasure¶
Find a file named “treasure.txt.” Navigate to it, retrieve the contents of the file, and share what you’ve discovered!
Open for Hint
Here are some ideas:
- Consider the
grep
command! - You can use
cat
,less
, or more to view the contents of a file. Like forman
, close the opened program by hittingq
. - Hard Mode: try using an editor like
vim
ornano
to read the file!
Challenge 2: Mysterious Sizes¶
Try to find the directoy with the biggest size in the folder we shared with you. Now try to find the largest individual file. Share the directory name (and/or file name), size, and the command you used to find it.
Open for Hint
Here are some ideas:
- Look into available flags for the
ls
command - Consider the
du
command, and play around with which flags you can use!
Challenge 3: The Time Traveler¶
Find a file with a modification date that is at least one month ago and change its timestamp!
Open for Hint
Here are some ideas:
- Recall we can us
ls -l
to view file details - Consider the
touch
command!
Challenge 4: The Artist¶
Create a new directory named “masterpiece” and populate it with text files, each containing a line from your favorite quote or poem. Use an editor (either vim
or nano
, but I recommend vim
!) to make your files. Share the commands you used to create and populate the directory.
Then, use a command to print out all your lines of poetry (across the files) one after the other.
Open for Hint
Here are some ideas:
- Utilize commands like
mkdir
to create folders. You can usevim
to generate files! - Consider the
cat
command to print your poems! - For printing all lines, there is a way with both
grep
andhead
, both of which use the wildcard*
!
Challenge 5: Pipe Explorer¶
Navigate to a directory containing multiple text files. Use a combination of commands and piping to find and count the number of lines in each text file. Share your results, showing the filename and the corresponding line count for each text file.
Open for Hint
Here are some ideas:
- Consider using
find
to locate text files andwc -l
to count lines.
Conclusion¶
Remember, the goal is to have fun and gain hands-on experience with Unix commands. Feel free to experiment and explore beyond the prompts. Happy scavenger hunting!