Assignment C

General instructions for all assignments

Provide an answer for each item in each session.
Number each answer with the same number as the corresponding item in the session assignment.
When the answer to the item is a Unix command, show the command and the system's response.
When the system prints more than 5 lines, abbreviate the response to 5 lines (unless more lines are specifically requested), showing the most important parts.
Use vi to create a file for each session, for example, create a file named sessionC1

Special instructions for Assignment C

During Assignment C you will be building a moderately large set of directories. To keep them all organized in your work, sketch a tree diagram of the directories and update it as you build them. At the end of the assignment you will be required to complete a drawing of the directory structure, which you can create from the sketch you built as you went along.

Because you will be changing directories, it is important to record what directory you were in when you issue a command. This should be done in Assignment C, and in other assignmnets dealing with multiple directories. Do this by copying the entire prompt into your solution of the assignment. For example for session C1 item 4.
4. [oldham@voyager letters]$ mkdir friendly formal

Session C1

  1. Log into the system.
  2. While in your home directory, make three directories named letters, reports, and assignments under your home directory.
  3. Change to directory letters.
  4. While in the letters directory, make two directories named friendly and formal under the letters directory.
  5. Change to the directory reports using only one command (directly from letters).
  6. While in the reports directory, make three directories named personal, business, and school under the directory reports using only one command.
  7. While still in the reports directory, make a directory named UNIX under the assignments directory.
  8. While still in the reports directory, make three directories named HWs, projects, and backups under the UNIX directory.
  9. Change to your home directory.
  10. While in your home directory, recursively list all of the directories you created. Using pencil and paper, draw a tree diagram with all these files and directories. (This sketch will be revised in Session C3.)
  11. You may log out, or continue with the following session.

Session C2

  1. Log into the system or change to your home directory.
  2. Change to the HWs directory.
  3. Check your present working directory.
  4. While in the HWs directory, use vi to create a file named hw3 that contains five lines, where each line contains the name and a very short description of a Unix command.
  5. While in the HWs directory, use vi to create a file named other that contains one line, containing the word hello
  6. Change to your home directory.
  7. While in your home directory, use wildcards to display all of the files you have created under the HWs directory.
  8. While still in your home directory, make a copy of hw3, name it hw3.copy and save it in the same directory where hw3 is stored (the HWs directory).
  9. While still in your home directory, check to see if both files (hw3 and hw3.copy) exist.
  10. Change to the HWs directory.
  11. While in the HWs directory, make a hard link to the hw3 file with the name hw3HL in your present working directory.
  12. While still in the HWs directory, make a soft link to the hw3 file with the name hw3SL in your present working directory.
  13. Use a command to check the inodes of hw3, hw3.copy, hw3HL, and hw3SL. Which ones are the same? Which ones have a different inode? Why are these inodes this way? (This response may total a maximum of 10 lines.)
  14. Use the   ls   command to find the file types of hw3, hw3.copy, hw3HL, and hw3SL Explain the result. (This response may total a maximum of 10 lines.)
  15. You may log out, or continue with the following session.

Session C3

  1. Log into the system or change to your home directory.
  2. Change to the UNIX directory.
  3. While in the UNIX directory, copy all your files in the HWs directory with names beginning with   hw   to the backups directory. Do all this with the one copy command.
  4. While still in the UNIX directory, use the find command to check the inode numbers of all files with names starting with   hw   in all the directories below the UNIX directory. Are the inodes all the same? Are the inode numbers in the HWs directory the same as in the backups directory? Why? (This response may total a maximum of 15 lines.)
  5. While still in the UNIX directory, use the find command to make a long listing of all files with names starting with   hw   in all the directories below the UNIX directory. What is different between the hw3SL file in the HWs directory and the hw3SL file in the backups directory? Why? (This response may total a maximum of 15 lines.)
  6. Change to the HWs directory.
  7. While in the HWs directory, delete the original hw3 that is in the HWs directory.
  8. While still in the HWs directory, use the command cat to look at the contents of the file hw3SL.
  9. While still in the HWs directory, use the command ls -l to look at the directory entry for the file hw3SL.
  10. Is hw3SL a soft link?   If it is a soft link, what does it link to?   If it is not a soft link, what is it? (This response may total a maximum of 10 lines.)
  11. While still in the HWs directory, copy the hw3 file from the backups directory to the HWs directory.
  12. While still in the HWs directory, check to see if hw3SL is now a valid soft link. Is hw3SL a valid soft link?
  13. Change to your home directory.
  14. While in your home directory, recursively list all the files and directories you have created in all the sessions of this assignment. Update the tree diagram that was created in session C1, adding all new files and directories.
  15. You may log out, or continue with the following session.

Session C4

  1. Log into the system or change to your home directory.
  2. While in your home directory, create a very short friendly letter, named friend.1, using vi and store it under the friendly directory.
  3. While still in your home directory, create a very short formal letter, named formal.1, using vi and store it under the formal directory.
  4. While still in your home directory, copy the file formal.1 and call the new copy file formal.2 which is also in the formal directory.
  5. While still in your home directory, make a small change in formal2 using vi.
  6. While still in your home directory, use one command using wildcards to print the contents of formal.1 and formal.2   (Remember that print in UNIX means print to the screen.)
  7. While still in your home directory, make a directory named busLetters under your home directory.
  8. While still in your home directory, move the formal directory (with all of its contents) into the busLetters directory.
  9. Log out of the system.

Submission session

Create a heading similar to the heading for assignment A.

Tommy Atkins   replace with your name
CIS 18A    
Winter 2011   replace with the current quarter
Assignment C  replace with the current assignment letter

  1. Use the following command to create a file with your work from the assignment:
    cat headingC sessionC1 sessionC2 sessionC3 sessionC4 > assignmentC.txt
  2. Use e-mail or WinSCP to obtain a copy of assignmentA.txt. Print it using notepad, or otherwise use the Courier New or other mono-space font.
  3. Turn in your printout to the instructor on time.