IT 244: Introduction to Linux/Unix
Answers to Mid-term Exam

  1. How do you you abort a running program?
    Control C
  2. What would you type at the command line to see all the files in the directory named /home/tsoro?
    ls  -a  /home/tsoro
  3. What is the name of the directory at the top of the Unix filesystem?
    root
  4. What symbol is used to represent the top of the Unix filesystem?
    /
  5. What is the parent directory?
    the directory directly above your current directory
  6. What is a startup file?
    a text file containing Unix commands that are run just before the shell gives you a prompt
  7. What directory is the starting point for an 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. If you have read permission on a directory, can you read the files in that directory?
    no, you need read permission on each file
  13. If you have write permission on a directory, what can you do in that directory?
    create a file or directory, delete a file or directory, rename a file or directory inside the directory
  14. If you have write permission on a directory to you have write permission on the files it contains?
    no, you need write permission on each file
  15. What does the PATH shell variable contain?
    the list of directories the shell must search to find the file to run a command
  16. Write two commands that will take you to your home directory, that is, make your home directory the current directory.
    Any two of the following are acceptable
    cd
    cd  ~
    cd ~UNIX_ID
    cd /home/UNIX_ID
  17. Look at the diagram on the last page. Assume that you are in /home/tsoro. Now write the single command you would use to go to the directory named frank using an absolute pathname.
    cd /classes/it/it244/frank
  18. Again, look at the diagram on the last page. Assume that you are in the directory /classes. Write the single command you would use to go to the directory /classes/it/it244/frank using a relative pathname.
    cd it244/frank
  19. Look at the diagram on the last page. Assume that you are in the directory /home. Write a single command to go to the directory /classes/it244 using a relative pathname.
    cd  ../classes/it/it244
  20. Look at the diagram on the last page. Assume that you are in the directory named frank. Write a command to create a symbolic link to the directory named classes.
    ln -s /classes
        or
    ln -s ../.. classes
  21. Write the single command you would use to move the directory named work from your home directory to your current directory.
    mv ~/dir .
  22. Write the single command you would use to create the file logged_on.txt which would contain a listing of all users currently logged on in reverse alphabetical order.
    who | sort -r > logged_on.txt
  23. Write the single command you would use to give the following permissions to the file work.sh.
    The owner should be able to do anything with the file.
    The group should only be able to read and execute the file.
    Everyone else should only be able to read the file.
    chmod 754 work.sh
  24. Write thesingle command you would use to to give the following permission to the directory dir1. The owner should be able to do everything.
    The group should be able to run ls and cd on the directory.
    Everyone else should have no permission on the directory.
    chmod 750 dir1
  25. The file red_sox.txt in your current directory has the format
            2011-07-02      Red Sox @  Astros       Win 7-5
            2011-07-03      Red Sox @  Astros       Win 2-1
            2011-07-04      Red Sox vs Blue Jays    Loss 7-9
            2011-07-05      Red Sox vs Blue Jays    Win 3-2
            …
    Write a command to find all Red Sox wins when they are not playing at home.
    When "vs" appears between the names of the two teams, it means it is a home game.
    grep  Win  red_sox.txt   |   grep -v  vs