CMPSC 311, General Instructions
Accessing Information -- How to get
the source code from APUE
Here is how to get your own copy of the source code from APUE, to be
on a Unix system with the GNU tools installed (this includes Linux, Mac
OS X, and Solaris at PSU CSE). We assume you are using a Web
browser where right-clicking on a link gets you a menu of choices; on
Mac OS X, use control-click instead. We also assume you have read
and printed this page on some not-necessarily-Unix system, because
we're going to start from
Login, and open a terminal window. You should be in your home
directory. Try these commands just to be sure.
When used as part of a command, the symbol
~ (tilde) is
shorthand for the name of your home directory. The environment
HOME gives the same information.
Create a directory to hold all your projects for the course. For
Verify that the directory was created.
Create a subdirectory to hold the code from APUE. For example,
The commands to follow will create a subdirectory of
Open a Web browser. For example,
Go to http://www.apuebook.com/
(right-click to open in a new tab or window, so you don't lose this
Click on Source Code in the left-side frame. You should see
The source code for the examples in the book is
for download here as a gzipped tar
Right-click on the link (here, there) in the right-side frame, and
select Save Link As ...
Browse to the directory you created earlier, and save the file as
which is its original name.
Now you need to unpack the source code files. We will add some
commands to see the effect of archiving and file compression.
First, change to your new directory.
gzip compresses a file, and
uncompresses it. The file name ends in
.gz as a
reminder. The program names begin with
indicate that they
are from the GNU collection, but that isn't a foolproof or absolute
src.tar.gz has been replaced by the file
which is about 7 times larger.
This is the typical use of
gzip src.tarTry this with interleaved
ls -l commands to verify
the file sizes and changes in the file name.
tar (which originally meant "tape archive")
bundles files and directories into one file, called a tar file or tar
archive for obvious reasons. The filename ends in
as a reminder.
tar also unbundles a tar file.
It's usually a good idea to see what is in the tar file before
tar tvf src.tar
tar does not use the modern convention for
options, which would have been something like "
tar -t -v -f
src.tar". The function letter
t means "Table
of Contents", so you get a listing. The function modifier
means "Verbose" so you get a long listing (file size and original date,
along with the name from the default listing). The function
f means "File" so you can specify which tar file
to read for its contents.
To extract the contents of the tar file,
tar xvf src.tar
Now check to see what you have:
You can safely delete the file
src.tar, since you know
how to recover it from the web site, and since its contents are now
available as individual files and subdirectories.
To see everything in the file tree,
Now it's time to read the files. Start with these,
more apue.2e/README apue.2e/DISCLAIMER
Navigating through the
apue.2e directory should be
obvious once you see its subdirectories and file names. Use the
to change to the subdirectory
subdir, and the command
to change to the parent directory (one level upward in the file
system), or the command
to change to your home directory.
Later we'll come back to the description of how to compile and run
Last revised, 28 Aug. 2008