Lab 7
(Chapter 7)
Learning Objectives
1. To learn how
to create a UNIX file structure (i.e., directory hierarchy)
2. To learn
about absolute and relative pathnames
3. To learn
about home directory, login directory, and present working directory (also known
as the current directory)
4. To learn how
to effectively navigate the UNIX directory hierarchy
5. To learn
about file types and hidden files
6. To learn
about the file attributes
Lab Work
Most of the work you will do in this
lab will be related to the following directory hierarchy.

- Log on to your UNIX system
- Build the above directory
hierarchy under your home directory, labeled as YHD Figure Lab7.1. Capture
below the whole shell session you needed to complete this work. Include
commands and their outputs in the session reproduced below.
- Display
the absolute pathname of your login directory.
- Suppose
that after login, you execute the
cd professional/courses
command. Answer the following questions.
- What
is the absolute pathname of your home directory? Show the command that you
used to obtain the answer to this question, along with the command output.
b. What is the
absolute pathname of the ‘acm’ directory?
c. Give two
relative pathnames for the ‘acm’ directory.
d. Execute the
cd major/cs381/labs command. Now execute a command to display the absolute
pathname of your current directory. Show your session.
e. Give three
different commands to get back to your home directory.
- Change
directory to /usr. How many files and directories are there in this directory?
What are the types of the files?
- How many
ordinary files, directories, and link files exist in the /usr/bin directory?
How did you obtain your answer? What are the names of directories?
- When you
log on, your UNIX system displays a message before displaying the shell
prompt. This message, called “message of the day,” is stored in the motd file
under the /etc directory. Display this message and capture your session below.
- The /etc
directory also contains a file that contains attributes for all the users who
have accounts on the system. A line in this file describes the user. What is
the name of this file? Display the line for yourself and display the session
below. Also write down the following information about yourself: user name,
user ID, group ID, personal information, home directory, and login shell.
- What
directory on your system contains the UNIX kernel executable and other files
and directories related to the UNIX kernel? Write down the name of the
executable kernel code.
- In UNIX
jargon, hidden files are those files whose names start with a dot (.) such as
.profile. Locate the .profile or .login file on your system. Where did you
find it? Partially show the contents of the file.
- Show
names of all hidden files in your home directory. Show your session.
- What are
the inode numbers of the following directories on your system: root, your home
directory, ~/temp, ~/professional, and ~/personal? Capture the session that
you had on your system to get your answers.
- Display
the type of contents of the file that contains the executable code for your
UNIX kernel. Show your session.
- Use a
text editor to create a file called lab1 under the labs directory in your
directory hierarchy. The file should contain the text of this problem. Answer
the following questions:
- What
is the type of lab1? Use a UNIX command to answer the question and capture
your shell session below.
- What
is the type of contents of lab1? Use a UNIX command to answer the question
and capture your shell session below.
-
Header files in UNIX have .h extension. Display the names of all header
file in the /usr/include/sys directory that start with the letter ‘t’. Show
your session.
- Log out.