UNIX Exercises

Thanks to Andrew Benson for developing these materials!

To access the starter code for these exercises, use the following command:

git clone /afs/ir/class/archive/cs/cs107a/cs107a.1226/WWW/exercises/unix


p1 (ls/cd)

The courses directory contains several quarters (which are directories), each of which contains several courses (which are also directories).

  1. Almost all of the courses contains a single file. One doesn't. Which one is it?
  2. Suppose you're in courses/aut21/cs103. How could you change directory into courses/aut21/math19? How about in a single cd command?
  3. The course from part1 has a hidden file inside. What's its name?

p2 (file processing)

The file wordlist.txt contains...a lot of words. Supposedly it contains all real English words. I actually don't remember where I got this file. I downloaded it at some point for use in brute-forcing puzzlehunts.

  1. Use the wc command to count how many there are. (man wc for a primer.)
  2. So it's probably in your best interest not to manually search the file...
    1. Is "celeriac" a real English word?
    2. How about "voluter"?

p3 (man)

  1. The tree command is a neat way to see the structure of a directory with a bunch of subdirectories. Try it out in the courses directory.
  2. If there's a lot of subdirectories, tree's output can get somewhat overwhelming. Use the manpage for tree to figure out how to limit the output of tree to two levels. When run on courses, the output should contain all course names but none of the files within.

p4 (tab autocompletion)

  1. There's a file inside the longname directory. What are its contents? How did you figure it out?

p5 (filesystem manipulation)

In the recipes directory, you'll see where I've been storing my recipes for different meals of the day. Help me fix some issues I've been meaning to address. (If you create any files, you can leave them empty.)

If you mess things up, go back to recipes and run ./reset.sh. Hopefully it should get you back to the initial state. Worse-case scenario, reclone this repository.

  1. Add a new recipe, bacon.txt, to recipes/breakfast/american.
  2. Oops, looks like one of my tax forms got inside the recipes/lunch directory! Delete it. (I have another copy somewhere else.)
  3. In the future, I might add some non-American recipes for lunch. In preparation, move the one recipe I have inside recipes/lunch into a new directory recipes/lunch/american.
  4. Rename the supper directory to dinner. It's too Midwestern for Californians. (Does this affect the contents of the directory?)j
  5. Oops, there's more tax files inside the [previously] supper/american directory??? And this time it's a whole directory of them. Delete it too. I have copies somewhere, I'm sure.
  6. Now the [previously] supper/american directory looks kinda empty. Make a copy of the one lunch recipe I had over here. Baked chicken can be eaten for either meal.