csci 26 :: midterm 1 (due mon, feb 24, AT START OF CLASS)
Submitting your work: Complete this exercise on your own.

Fill in all of the "Answer" boxes, then print the answer grid that you see after you press "Prepare for printing".

Staple all pages together and submit to the instructor on the date listed above.

YOU MUST HAVE YOUR MIDTERM PRINTED WHEN YOU ARRIVE IN CLASS. YOU WILL NOT BE ALLOWED TO PRINT YOUR MIDTERM IN CLASS ON THE DAY IT IS DUE.

Questions:

This midterm covers all of the concepts you encountered on Daily Challenges 1, 2, 3, 4, 5, 6, and 7.

Your name:
  1. What is the codename for each of the following versions of the Debian Linux distribution?
    • current stable version
    • current testing version
    • current unstable version

    Answer:
  2. What is the name of the utility that allows a user to execute a command with the root user's privileges? What configuration file must be edited to give a user the right to use this utility?
    Answer:
  3. What is the name of the standard package management system in Debian?
    Answer:
  4. Write the command to display the effective user id.
    Answer:
  5. What is the default shell in Debian?
    Answer:
  6. Write the command to display the present working directory.
    Answer:
  7. Write the commands to perform each of the following actions:
    • move up one directory
    • move up two directories
    • move down to the subdirectory "working"
    • move to the directory "/var/log"

    Answer:
  8. Write four (4) different commands to move to your home directory.
    Answer:
  9. Write the command to view the manual page for the utility "find".
    Answer:
  10. Write the command to find all files on the system owned by the user "janedoe".
    Answer:
  11. Write the command to find all files on the system owned by the user "janedoe". Redirect all of the error output to a file named "find-errors.txt" (create/overwrite this file).
    Answer:
  12. Write the command to display every occurrence of the pattern "find" in your shell commmand history.
    Answer:
  13. Write the commands to perform each of the following actions:
    • list the contents of the present working directory
    • list the contents of the present working directory, in long format
    • list the contents of the present working directory, including all hidden files
    • list the contents of the present working directory, in long format and including all hidden files
    • list the contents of the present working directory, with a "/" after directory names and a "*" after executable names

    Answer:
  14. Write the command to append the output of the "date" command to a file named "mylog.txt".
    Answer:
  15. Write the command to count all files in the system owned by the user "janedoe".
    Answer:
  16. Write the command to filter out all duplicate lines in the file "inventory.txt", writing the output (create/overwrite) to the file "inventory-clean.txt". Assume that "inventory.txt" is not sorted.
    inventory list with duplicate lines
    Answer:
  17. Write the commands to perform each of the following actions. The format of the input file is given below.
    PRODUCT_TYPE PRODUCT_NAME PRODUCT_PRICE NUMBER_IN_STOCK
    inventory list without duplicate lines
    • sort the file "inventory-clean.txt" on the key field PRODUCT_NAME
    • sort the file "inventory-clean.txt" on the key field NUMBER_IN_STOCK (output should be sorted by least to most NUMBER_IN_STOCK)

    Answer:
  18. Write the command to join the files "inventory.txt" and "ship_to.txt" so that each output line shows both the information about an item in the inventory and the store to which the item is to be shipped. All tools should ship to "Hardware Store", all fruit to "Fruit Stand", and all vegetables to "Market", for example:
    tool hammer 9.99 5 Johnson's Hardware Store
    inventory list without duplicate lines
    Answer:
  19. Write the commands to perform each of the following actions:
    • display the first 5 lines of the file "todo-list.txt"
    • display the last 25 lines of the file "/var/log/auth.log"

    Answer:
  20. Write a regular expression that will match any of the following patterns:
    cat Cat hat Hat pat Pat rat Rat sat Sat
    Answer:
  21. Write a regular expression to match dates in the following format. You do not have to worry about limiting the regex to valid months/days -- just write the regex to match the pattern "2 digits/2 digits/4 digits".
    02/12/2014
    Answer:
  22. Write the commands to perform each of the following actions:
    • add the user "jdoe" and create the user's home directory
    • lock out the user "jdoe"
    • require "jdoe" to change her/his password every 180 days
    • delete the user "jdoe", removing all files and the mail spool associated with this account

    Answer:
  23. Write the commands to perform each of the following actions:
    • create a new group named "artists"
    • add the user "jdoe" to the group "artists"; given that "jdoe" is already a member of the groups "staff" and "musicians", be sure to preserve the user's membership in these groups
    • delete the group "slackers" -- assume that the group has no members

    Answer:
  24. Write the commands to perform each of the following actions:
    • copy the file "backup-1.tar.gz" to a file named "backup-last.tar.gz"
    • copy the directory "backups" and all of its subdirectories into a directory named "old-backups"
    • rename the directory "bkups" to "backups"
    • create a directory named "recent-backups"
    • remove a directory named "stale-backups" including all of its files and subdirectories; use the option to disable the confirmation prompt and any diagnostic messages

    Answer:
  25. Write the commands to perform each of the following actions:
    • extract the contents of the archive "/tmp/backup-1.tar.bz2" to the present working directory
    • create and compress (using gzip) a tape archive named "backup-2.tar.gz" that contains all of the contents of the directory "working" (which is a subdirectory of your present working directory)

    Answer:

Total points for this midterm exam:

250 points