csci 26 :: final exam (submit by 3pm, tues, may 26)
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.

Questions:
Your name:
  1. Write the command to install the package "apache".
    Answer:
  2. Write the command to display/print the value of the shell variable $PATH in the terminal.
    Answer:
  3. Write the command to view the manual page for the "tar" utility.
    Answer:
  4. Write the BASH shell command to redirect the output of the command "ls -l" to a file named "listing.txt". Use the redirection operator to create/overwrite the file.
    Answer:
  5. Write the BASH shell command to redirect the output of the command "date" to a file name "work.txt". Use the redirection operator to append to the file.
    Answer:
  6. Write the BASH shell command to redirect the error output of the command "find / -user testuser" to /dev/null.
    Answer:
  7. Write the BASH shell command to connect the output of the command "find / -user testuser" to the input of the command "wc -l".
    Answer:
  8. Write the regular expression that will match a pattern that starts with any single character, followed by "at" (such as "cat" or "bat" or "$at" or "3at"). Do not include quotes in your regex.
    Answer:
  9. Write the single regular expression that will match both of these patterns: "Fez" and "fez". Do not include quotes in your regex.
    Answer:
  10. Write the grep command to locate and display the line number where the pattern "ERROR" appears in the file "log.txt".
    Answer:
  11. Write the command to change the passwd for the user "testuser". Assume you are root when you execute this command.
    Answer:
  12. Write the command to force the user "testuser" to change passwords every 30 days.
    Answer:
  13. Write the commands to do each of the following:
    • to create a new group called "testgroup"
    • append "testuser" to the supplementary group "testgroup"
    • list all groups in which "testuser" is a member

    Answer:
  14. Write the commands to do each of the following:
    • create a tar archive of the contents of the directory "backup_stuff" -- name the archive "backup_stuff.tar"
    • compress the tar archive "backup_stuff.tar" using gzip
    • use a single command (do not use pipes) to uncompress and extract the contents of the archive "backup_stuff.tar.gz" to the present working directory

    Answer:
  15. Write the command to change the owner of the file "some_file.txt" to the user "testuser" and the group "testgroup"
    Answer:
  16. Write the command to set the mode/permissions of the file "some_file.txt" to the following, using octal representation:
    1. user: read, write, and execute
    2. group: read and execute
    3. other: read

    Answer:
  17. Write the command to remove the read permission of other from the file "some_file.txt", using symbolic/mnemonic representation.
    Answer:
  18. What directory does the Filesystem Hierarchy Standard specify for storing miscellaneous log files? Does Debian use this directory for its miscellaneous log files?
    Answer:
  19. Write the command to output and "follow" the last 10 lines of the "messages" log, using the full path to the "messages" file on the system (do NOT assume messages is in your present working directory).
    Answer:
  20. Briefly describe shadow passwords. Does Debian use shadow passwords?
    Answer:
  21. Write the command to start an SSH connection for the user "testuser" on the loopback device (IP 127.0.0.1).
    Answer:
  22. What configuration file would you edit to disable root login via SSH? Provide the full path to the file.
    Answer:
  23. Write the command to define the shell variable COLOR and set is value to "red".
    Answer:
  24. Write the command to display the value of the shell variable COLOR.
    Answer:
  25. Write the command to make the shell variable COLOR available to child shells.
    Answer:
  26. Write the command to change your default bash prompt to ">".
    Answer:
  27. Write the command to create "countfiles" as an alias to the command "ls | wc -l".
    Answer:
  28. Which of the following files is processed by bash during an interactive login?
    1. ~/.bash_profile
    2. ~/.bashrc

    Answer:
  29. Which of the following files is processed by bash during an non-interactive login?
    1. ~/.bash_profile
    2. ~/.bashrc

    Answer:
  30. Write the line that should appear at the top of a bash script on your Debian system.
    Answer:
  31. Write the command to make the bash script "test_script.sh" executable, using symbolic/mnemonic representation.
    Answer:
  32. Write a complete bash shell script to do the following:
    1. print the message "What is your favorite food?"
    2. read in the user's answer to the question, storing the input into a shell variable named FOOD
    3. print the message "I have never tried _____" (replace the blank with the value of the variable FOOD

    Answer:
  33. Write a complete bash shell script to do the following:
    1. print the message "Guess the secret number:"
    2. read in the user's answer to the question, storing the input into a shell variable named GUESS
    3. print the message "Too high" if GUESS is greater than 42
    4. print the message "Too low" if GUESS is less than 42
    5. print the message "You got it!" if GUESS is exactly 42

    Answer:
  34. Write the implementation for a shell function named "multiply" that does the following:
    1. tests the number of arguments supplied to the function -- if the number of arguments is not exactly 2, print the message " Usage: multiply NUM1 NUM2"
    2. otherwise:
      1. use the bc utility to compute the value of NUM1 * NUM2 and store the result into a shell variable named RESULT
      2. print the message "_____ * _____ = _____" (replace the blanks with the values of the parameters and the result)

    Answer:
  35. When will the following cron job run?
    30 * * * * /etc/scripts/script.sh
    Answer:
  36. Write the command to display the crontab for the user "testuser".
    Answer:
  37. What is the primary file used on a Debian system to configure sources for APT packages?
    Answer:
  38. Write the dpkg-query command to list all installed packages.
    Answer:
  39. Write the apt-cache command to display information about the APT package cowsay.
    Answer:
  40. Write the command to print the kernel name, kernel release, and machine hardware for your system.
    Answer:
  41. Write the command to display all processes on your system, in full format.
    Answer:
  42. Write the command to display real-time information about all processes owned by the user "testuser".
    Answer:
  43. Write the command to send the SIGHUP signal to the process with PID 1234.
    Answer:
  44. What is the default boot loader on Debian Wheezy?
    Answer:
  45. Write the command to view messages generated by the kernel, such as messages generated when a system is booted (HINT: these messages are stored in the kernel ring buffer).
    Answer:
  46. Write the "shortcut" commands (i.e., not using the shutdown utility) to do each of the following:
    1. halt the system (without powering down)
    2. reboot the system
    3. power down the system

    Answer:
  47. Write the fdisk command to print/list all of the partitions on your system.
    Answer:
  48. Write the command to display disk usage for the home directory of the user "testuser", in human readable format.
    Answer:
  49. What two desktop environments are considered to be the most dominant and fully-featured desktop environments for Linux?
    Answer:
  50. What does LAMP stand for, in a UNIX/Linux server context?
    Answer:

Total points for this final exam:

750 points