| |
Symbolic Links
Due: Monday January 18, 1999
Hand in your output during class on Monday. (I expect you to complete most of the
lab during Friday.)
Purpose:
Review understanding of the Unix file system.
Assignment:
There is an option to the "ls" command that lists the Unix "i-node"
number of each item named in a directory. You will find that option useful in doing this
lab.
- Directory ~ian/maze/ is owned by ian and has
Unix "inode" number 1913184257. Show the command line that
tells you this, along with its output (cut-and-paste).
- This directory with inode number 1913184257 is named "maze".
Where is the name "maze" stored? Show the owner and inode
number of the place where the name "maze" is stored
(cut-and-paste).
- Show the command line that can summarize the disk usage (the amount of disk space used
by all the items) in this directory, along with its output (cut-and-paste).
- There are 9 files in this directory. Does the amount of disk space used add up
correctly? Why or why not?
- In three columns, give the name, inode number, and type of
each of the items whose names are stored in the "maze"
directory. Show all the names (including hidden names) and the inode numbers that are
present in the directory. Your table will look something like this (you can steal this
HTML and fill in your own table!):
Directory Inode Number 1913184257 |
Name in Directory |
Inode Number |
Type of Item |
somename |
123456 |
file containing text "Happy Day" |
othername |
234567 |
symbolic link to "burfl" |
morename |
345678 |
directory |
...etc... |
...etc... |
...etc... |
- Write a Unix shell script that creates a directory structure identical to that of ~ian/maze/
in a new directory named "maze" in the current directory of the
person running the shell script. The script will be a set of Unix commands that,
when run, will create the directory "maze" and create files,
links, and symlinks identical to the structure in ~ian/maze/,
all owned by the user running the script.
If your shell script were run in the /tmp
directory, the script would create /tmp/maze/ and then create
the exact set of files, links, and symlinks as found in ~ian/maze/.
Set your Unix PATH to something unusable, export it, and then try test-running your
maze-creating shell script. (e.g. PATH=/dev/null; export PATH;
./makemaze) Does your script still work? Fix the script so that, no
matter what PATH exists in the environment, the script sets and uses a PATH internally
that allows all the commands called in the script to be found correctly.
Your script should not copy the contents of ~ian/maze/;
it should execute the necessary Unix commands to create an identical directory from
scratch. Do not use Unix commands to simply copy the existing directory; recreate
the structure. Hand in a copy of your script and the output of "ls -la
maze" on the new maze directory it created.
- In the "maze" directory you create with your script:
| Delete the symbolic link name "d" from your directory. Which
names in the directory no longer lead to anything useful? Explain. |
| Delete the file name "finish" from your directory. Which
names in the directory no longer lead to anything useful? Explain.
|
Describe the difference in output between the following two sequences of commands, one
of which uses hard links and the other symbolic links. Why is the output different?
$ echo Venus >start
$ ln start startcopy
$ rm start
$ echo Mars >start
$ cat start startcopy
$ echo Apple >one
$ ln -s one onecopy
$ rm one
$ echo Orange >one
$ cat one onecopy
Hand in:
Hand in, on paper, the answers to the above questions.
Additional material:
|