Background and inspiration. Figuring out how to run scientific software through a command-line interface is a key skill for students exploring bioinformatics. There are many good resources that explain how to navigate around one’s computer using interfaces like BASH, the MacOSX Terminal, or Windows PowerShell. However, many of the tutorials that I explored when looking for resources for my students were pretty dry. I wanted something I could give to students on the first or second day of class, and get them hooked on using command line interfaces for the rest of the term. In classes that mix students with a wide range of computational expertise, I also wanted something that would be fun and engaging even if you are already familiar with using the command-line.
Sean O’Neil , a bioinformatics trainer at Oregon State University, does a masterful job of explaining the concept of directory structure and how to navigate it on the command-line. While explaining this idea, he drew a little stick figure onto the tree of directories to represent the user’s current location – the current working directory. I liked this metaphor that each directory is a place, and that commands like cd represent walking yourself from place to place. It seemed to resonate with students.
In this short teaching module, I’ve taken this metaphor and extend it into a short choose-your-own-adventure style exercise. In the exercise, students explore a whimsically haunted mansion, trying to find their little brother. Each directory represents a different location along the way. There are many surprises – from hidden passageways to a dragon- to be found along the way.
Educational goals:
- Improve understanding of directory structure, absolute paths, and relative paths
- Gain comfort and familiarity with navigating on the command-line using the commands cd, ls, pwd.
- Understand how to read a text file with more or to edit a text file with pico.
- Understand how to move a file with mv
- Using tab-completion to reduce errors due to typos and go faster
- Reusing previously issued commands
Time required:
I usually spend 60-90 minutes introducing the command-line, including a mini-lecture and the exercise. Of that, I would expect to spend anywhere from 45-60 minutes on the exercise. Some students who already know how to navigate the command line will finish earlier (but may still tend to take some time exploring the different areas).
Materials:
Handout with summary of common commands: Commandline_Cheatsheet.pdf
The zipped directory structure for the exercise: treasure_hunt.zip
Example introductory slides: Commandline_treasurehunt_slides
Students will need a Windows or MacOSX computer/laptop with internet access, one handout each, a piece of blank paper, and a pen.
Instructions:
I give an intro using some version of the PowerPoint slides linked above, and give everyone the handout. After the intro, I demonstrate how to open PowerShell on Windows or Terminal on MacOSX.
I then explain how to download the materials (there are some tricks to this- see hints below).
Finally, I tell students to map the directories that they explore and label what they find. This forces students new to using the command-line to keep track of where they are and the location of different locations relative to one another. It could probably make a good worksheet, but so far I’ve just had them do so on a piece of blank paper.
As they wander around the mansion, they are looking for their little brother, who they want to return to the directory labelled home_sweet_home (by using the mv command). Bonus points if they can return magical creatures to the zoo and assemble the ingredients for a tasty mushroom soup.
There is an instructions.txt file in the first directory that gives an overview of what to do and reviews some useful commands with examples.
Hints:
- Expect to spend some significant hands-on time with students at the start of the exercise. For larger groups, it is very useful if you have some helpers or more experienced students who know enough to help others get set up.
- There is a certain chicken-and-the-egg problem with doing an exercise on navigating the command line. Many undergraduate biology students won’t know that their computer has directories, much less how to save a file in a specific one. So if they start by downloading the exercise materials to an arbitrary directory, they won’t know how to get to it on the command line, since that’s what the exercise is supposed to teach! Here’s what I do instead: FIRST show the students how to find the terminal or PowerShell, SECOND have them use the pwd command to find the absolute path for their current directory and only THIRD have them download the zipped directory structure into their current working directory (you’ll have to explain how to right or control-click and select ‘Save As…’).
- The details of platform-specific differences in commands can take a long time to explain. For example, Windows PowerShell has different commands than bash or the MacOSX terminal. I’ve tried to emphasize commands that have aliases across all systems, meaning that even if they wouldn’t necessarily be how a PowerShell user would first think to enter a command, they’ll still work on that platform.
- While most students seem to very much enjoy the exercise, it might be a good idea to have handy a regular set of file folders from a recent analysis project in case there is a student that for whatever reason finds the theme distracting.
- As I show students cd, ls, etc, I try to emphasize that these are all just programs, with arguments and parameters.
- At the end of the exercise, be sure to re-emphasize that this is just a series of folders and text files, just like all others on their machine. Some students who have never seen a command line interface before might think this is some sort of actual game. It would be useful to practice the same commands for a bioinformatics-oriented task in the next lesson to drive home this point.
- If you’re using this in a workshop that uses a central server, you can place the exercise in a publicly accessible directory, then have students connect to the server and copy a version to their home directory to get started. In some ways this is probably a little bit easier than downloading locally.
Feature image credit: Das Geisterhaus, Harald Hoyer from Schwerin, Germany (Wikipedia Commons)