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).
- Almost all of the courses contains a single file. One doesn't. Which one is it?
- Suppose you're in
courses/aut21/cs103
. How could you change directory intocourses/aut21/math19
? How about in a singlecd
command? - 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.
- Use the
wc
command to count how many there are. (man wc
for a primer.) - So it's probably in your best interest not to manually search the file...
- Is "celeriac" a real English word?
- How about "voluter"?
p3 (man
)
- The
tree
command is a neat way to see the structure of a directory with a bunch of subdirectories. Try it out in thecourses
directory. - If there's a lot of subdirectories,
tree
's output can get somewhat overwhelming. Use the manpage fortree
to figure out how to limit the output oftree
to two levels. When run oncourses
, the output should contain all course names but none of the files within.
p4 (tab autocompletion)
- 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.
- Add a new recipe,
bacon.txt
, torecipes/breakfast/american
. - Oops, looks like one of my tax forms got inside the
recipes/lunch
directory! Delete it. (I have another copy somewhere else.) - 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 directoryrecipes/lunch/american
. - Rename the
supper
directory todinner
. It's too Midwestern for Californians. (Does this affect the contents of the directory?)j - 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. - 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.