Name:
Date:
Lab 2 – Navigating
the Unix File System
Introduction
- In this lab you will apply the skills you have learned
in your Introduction
to Unix lab. You will practice creating files and directories, and
navigating your directory structure using pathnames relative to your home
directory.
- Even though pathnames are amazingly simple, they're one
of the biggest problems beginners have. Working through this lab carefully
and understanding your steps will save you a lot of time and frustration
in the future.
Due
- Hand in this completed lab sheet at the end of
the session designated for this work, or at a time mutually agreed to by
you and the instructor.
Worth
Lab Steps
Step 1 – Creating a Unix file structure
- Log in to your CS department Unix account following these
instructions.
-
CHALLENGE: Do NOT use
the
cd (change directory) command in
this lab. Specify all paths relative
to your home directory.
|
|
Create the following Unix
structure in your home directory
To create a directory, use the mkdir command. To create a file, use the
editor pico.
For example, to create the file concat.c in
the directory strings (assuming that you
have already created the directory structure), type in
pico ~/csc2400/strings/concat.c
The contents of the file are not
important for this exercise, so simply type in any string you want (for
example, “This is the file concat.c”), then save it with Ctrl-O (see the menu at the bottom of the editor
window) and hit Enter, then Ctrl-X to exit. To make sure that the file has been
created, display the contents of the strings directory
ls
~/csc2400/strings/
You should see the name of the file
listed. To display the file contents, use
more
~/csc2400/strings/concat.c
- Use the ls command multiple times to verify that you have created
the correct structure.
- Report success or failure to the
instructor and have the instructor or TA initial here: _______
- ALTERNATIVE TO INITIALS: If you work through this tutorial on your own,
briefly describe here in writing what you did and what you learned:
Step 2 – Modifying the Unix file structure
1. Make
a copy of the entire file structure you created in step 1, so you can revert to
it in case you accidentally delete something:
cp
-r ~/csc2400 ~/csc2400copy
In the following
refer to the original copy your file structure (the one depicted above).
2. What
is the path to projects relative to your home
directory?
3.
What is the path to pointers relative
to your home directory?
4.
Make a copy of the pointers directory
under the projects directory.
5.
Make a copy of the overflow directory
under the csc2400 directory, then delete the original copy.
6.
Move the file tutorial.html
in the memory directory.
7.
Copy the file stack.c in your home
directory and rename it hello.c.
8.
Remove the strings directory
(and its contents).
9.
Rename blocks.txt
to blocks.mm
- The new directory structure should
be as shown above. Use multiple ls commands to verify it.
- Report success or failure to the
instructor and have the instructor or TA initial here: _______
- ALTERNATIVE TO INITIALS: If you work through this tutorial on your own,
briefly describe here in writing what you did and what you learned: