Beginner Lab 1 - Unix, the Shell, OSS
Welcome to the first lab! Here are some commands you might find helpful:
cat, cd, emacs, file, grep, less, ls, man, nano, tar, wget, vim
Remember: Google and man
are your friends!
Shell spelunking
Everything should be done via the shell!
The purpose of this lab is to get you comfortable with using the shell for
things you might typically use a GUI for. While these tasks may seem simplistic
or limited, you’ll quickly find that the commands have many different options
(flags) to perform tasks that are either impossible or incredibly tedious /
difficult to complete using traditional methods.
-
ssh
into tsunami.ocf.berkeley.edu
using your OCF account, or login at
ssh.ocf.berkeley.edu
-
Run the following command to download the file we have provided:
wget https://decal.ocf.berkeley.edu/static/b1/b01.tgz
A .tgz
file is actually a composition of two file formats. Sometimes
you’ll see these files as .tar.gz
instead. A common (and old) way of
archiving is with magnetic tapes. However, in order to archive the data, it
needs to be a single file, and often you want to archive multiple files at
once. This is where the tar
command comes in (tar
stands for tape
archive). Tar will group (or ungroup) multiple files into a single one.
tar
, unless you ask it to, doesn’t compress files itself though. This is
where either gzip
(or bzip2
) comes in. gzip
will compress your file,
and so, tar + gzip is often used in conjunction. It looks something like
this: file --(tar)--> file.tar --(gzip)--> file.tar.gz
.
If you read the tar
documentation carefully enough, you’ll see that you
can give the command an option to compress your files using gzip
as well,
saving you a total of one line of shell command!
To unarchive the file we provide you, run the following command:
tar xvzf b01.tgz
. This will provide a b01
directory for you with some
files for the rest of this lab.
tar
has a reputation for being a bit tricky with its options:
-
Go into the b01
directory. Make sure you’re in there by running pwd
(Present working directory). What does pwd
give you?
-
There’s a hidden file in the b01
directory. What is the secret?
-
A malicious user made its way into my computer and added a bunch of nonsense
files. What do the files say? (Hint: They all have the same contents). Help
me get rid of them by deleting all of these files and the directory they are
in.
-
There’s a file in b01
called big_data.txt
. It’s 80 megabytes worth of
random text. For reference, Leo Tolstoy’s “War and Peace”, the novel with a
whopping 57,287 words depicting the French invasion of Russia and the impact
of the Napoleonic era on Tsarist society through the stories of five Russian
aristocratic families with several chapters solely dedicated to
philosophical prose, is only 3.2 megabytes large.
For that reason, I don’t recommend using cat
to print the file. You can
try it, but you’ll be sitting there for a while. There’s some text you need
to find in there! Go find it without actually opening up the file itself!
(Hint: It’s a url)
Two lines above the URL is a secret solution. What is that solution?
Hint for this one: “Context Line Control”
-
There’s a file called trojan_horse.txt
. Try reading it using less.
Surprise! It’s not a text file. Find out what kind of file it is.
-
Finally, there’s an empty file called hello_world
in the directory. Write
your name in it!
-
Once you’re done remember to fill out the Google
form. There’s some other questions
you’ll have to answer and some feedback we’d like you to fill out!