IT 244: Introduction to Linux/Unix
Answers to Midterm Exam - Odd Columns

  1. What command would you use to keep a record of every command you type and the output of those commands?
    script
  2. How do you you abort a running program?
    Control C
  3. What would you type at the command line if you wanted to see the value of the variable SHELL?
    echo  $SHELL
  4. What would you type at the command line if you wanted to find all lines in the file results.txt that DID NOT contain the word "homework"?
    grep -v homework  results.txt
  5. What would you type at the command line if you wanted to see all the lines in numbers.txt sorted in REVERSE NUMERIC order?
    sort -nr numbers.txt
  6. What directory are you in when you first log in to a Unix machine?
    your own home directory
  7. What directory is the starting point for EVERY absolute path?
    the root directory
  8. What directory is the starting point for a relative path?
    the current directory
  9. By default, which account is the owner of a file or directory?
    the account that created it
  10. Name the three types of access permissions.
    read, write and execute
  11. Name the three categories of accounts which are used in assigning access permissions.
    owner, group, everyone else
  12. Who can change the access permissions on a file or directory?
    only the owner
  13. What does the PATH shell variable contain?
    the list of directories the shell must search 
    to find the file to run a command
  14. What does a program do just before it stops running?
    it sends an exit status to the shell
  15. What does an exit status of 0 mean?
    it means that the program encountered no errors
  16. Look at the diagram on the last page.
    You are in the directory named it.
    Write the ABSOLUTE pathname for the directory named hw2 under the it244 directory.
    You do not have to write a Unix command, I only want the pathname.
    /courses/it/it244/hw/hw2
  17. Look at the diagram on the last page.
    You are in the directory named courses.
    Write the RELATIVE pathname for the directory named hw1 under the it116 directory.
    You do not have to write a Unix command, I only want the pathname.
    it/it116/hw/hw1
  18. Look at the diagram on the last page.
    You are in the directory named it117.
    Write the RELATIVE pathname for the root directory.
    You do not have to write a Unix command, I only want the pathname.
    ../../..
  19. Look at the diagram on the last page.
    You are in the directory named bob under home.
    Write the RELATIVE pathname for the django directory under projects.
    You do not have to write a Unix command, I only want the pathname.
    ../../projects/django
  20. Look at the diagram on the last page.
    You are in the directory gh.
    Write the command to create a soft link to the hw2 directory under the it244 directory.
    You may use either an absolute or relative pathname.
    ln -s /courses/it/it244/hw/hw2
  21. Write a SINGLE command to copy the file memo.txt from your parent directory to your current directory.
    cp  ../memo.txt  .
  22. Write a SINGLE command that will change the permissions on the FILE do_something so that the owner can do anything with the file, the group can read and execute it, and everyone else can only read the file.
    chmod  754  do_something
  23. Write a SINGLE command that will change the permission on the DIRECTORY dir1 so that the owner can do anything in the directory, the group can run ls and change the names of files in the directory, and everyone else can only run cd on the directory.
    chmod  761  dir1
  24. What is the name of the only program that can create a process?
    the kernel
  25. What would you write on the command line to remove the directory dir1 in your parent directory.
    Assume this directory is empty.
    rmdir ../dir1