CS205 Introduction to UNIX

Review for Third Quiz: Chapters 7, 8, 9, and 11
  1. Redirection is
    1.  getting directions for a task
    2.  getting input from or sending output to a different place
    3.  saving to a file
    4.  multitasking

  2. What are the four redirection operators?

    1.  _______
    2.  _______
    3.  _______
    4.  _______

  3. What is at least one use for each kind of redirection?

    1.  __________________________________________
    2.  __________________________________________

  4. Assume you have a file called myfile. Write a command that could be used to view the file using each listed command.

    1.  cat _______________________________________
    2.  vi ________________________________________
    3.  echo ______________________________________

  5. What is one use for each of these commands?

    1.  mv ______________________________________
    2.  cp ______________________________________
    3.  pg ______________________________________

  6. The ln command is used,

    1.  to display line numbers
    2.  to locate names
    3.  to create links
    4.  to honor Les Nesman

  7. Assume you have a file called bigfile. What would each of these commands return to you?

    1.  wc -w bigfile ______________________________________
    2.  wc bigfile ______________________________________
    3.  ls > wc -l ______________________________________

  8. What does each of these commands do?

    1.  rm bigfile ______________________________________
    2.  rm bigfile* ______________________________________
    3.  rm bigfile * ______________________________________

  9. What does each of these escape sequences stand for to the echo command?

    1.  \n ______________________________________
    2.  \b ______________________________________
    3.  \t ______________________________________
    4.  \r ______________________________________

  10. grep is a search program. Write a grep command to do each of the following:

    1.  list all files in my home directory containing my name
    2.  show all lines containing my name from the files above
    3.  list all lines in myfile that do not contain my name

  11. Which of these will print a personal greeting to a user?

    1.  echo Hi.
    2.  echo Hello, USER.
    3.  echo Hello, $USER.
    4.  Echo Hello, Sailor.

  12. What is the command to:

    1.  save your first name in your USER variable
    2.  echo a message to the screen including the system date
    3.  save your whole name with a space in your USER variable

  13. What are the differences between double quotes, single quotes, accents grave, and the backslash?

  14. Explain the difference between these by explaining what each command does.
    1.  Cat myfile date pwd
    2.  cat myfile ; date ; pwd
    3.  cat myfile ; date ; pwd > newfile
    4.  (cat myfile ; date ; pwd) > newfile

  15. What is the difference between correct use of the pipe and the output redirection operator?

  16. Explain how to use the tee command.

  17. Back to grep: what is each of these options for?

    1.  -i ______________________________________
    2.  -n ______________________________________
    3.  -vc ______________________________________

  18. The sort command sorts in ASCII order unless you use these. What is each for?

    1.  -d ______________________________________
    2.  -n ______________________________________
    3.  -f ______________________________________
    4.  -r ______________________________________

  19. The sort command can sort on fields. What do these do?

    1.  sort +1 phone.list
    2.  sort -b +2 phone.list
    3.  sort phone.list

  20. Name three hidden startup files we would expect to find in your home directory, and state what they are for.

  21. What is the UNIX command to send a message directly to the screen of user GeorgeW?

  22. What command should GeorgeW enter to avoid the message above?

  23. If the system operator wants to send a message to all users, NOW, what is the command?

  24. Our author described the use of the mailx command. What is the mailx command to:

    1.  view your messages
    2.  compose a message to GeorgeW
    3.  send myfile directly to GeorgeW in an e-mail

  25. What is the difference between the q and x commands when reading mailx e-mail?

  26. What command would you type to create a mail group called Friends? Include three users in the group.

  27. What file should the above command be stored in to make the group available to you in every session?

  28. Explain two differences between programs and scripts.

  29. Explain two ways scripts and programs are alike.

  30. How do you put a remark in a shell script? Why would you do so?

  31. Assume you have created a new script called MyFirst. What command is used to enable users to execute the script?

  32. Assume the situation in the question above. User proper syntax to give all rights to yourself, read and execute rights to your group, and no rights to others on the system.

  33. Explain the use of the three allowable math operators when using the chmod command: +, -, and =.

  34. Write a script that does the following:
    1. create a variable called Name
    2. ask the person running the script to enter their name
    3. capture what the user enters, and store it in the Name variable
    4. output a message to the user, using the captured data in the message