CS211 Shell Programming

Review for First Quiz

  1. What are the 3 main parts of UNIX?
    1.  Larry, Moe and Curly (and sometimes Shemp)
    2.  kernel, file system and shell
    3.  ls, wc and grep
    4.  command.com, file system and kernel

  2. Which of the following shells is most commonly available, already installed on a UNIX system?
    1.  Bourne
    2.  Korn
    3.  C
    4.  Bourne-again

  3. Which shell listed above is started by each of these programs?
    1.  bash ____________________
    2.  csh _____________________
    3.  ksh _____________________
    4.  sh ______________________

  4. The purpose of the shell is
    1.  to interpret commands
    2.  to protect the user from the files
    3.  to protect the snail from fish
    4.  to carry out commands

  5. What is the UNIX command to print the value of the variable called count?
    1.  print count
    2.  echo count
    3.  echo $count
    4.  cat count

  6. What is the command to take input from the user and store it in the variable count?
    1.  read $count
    2.  read count
    3.  get &count
    4.  get count

  7. UNIX file structure is usually compared to...
    1.  a branching tree
    2.  a single folder
    3.  a series of nodes
    4.  a throbbing ache in the lumbar area

  8. Which characters should not be used in filenames?
    1.  uppercase letters
    2.  lowercase letters
    3.  metacharacters
    4.  underscores and periods

  9. Which metacharacter best matches a single character in filename expansion?
    1.  question mark
    2.  square bracket
    3.  period
    4.  asterisk

  10. UNIX files and directories have three kinds of permissions:
    1.  read, copy and execute
    2.  copy, read and write
    3.  read, write and execute
    4.  write, erase and execute

  11. UNIX permissions apply to three kinds of users:
    1.  owner, group and others
    2.  administrator, owner and group
    3.  friends, Romans and countrymen
    4.  network, LAN, and WAN

  12. What chmod command would you use on a file to let all system users execute it?
    1.  chmod 770 filename
    2.  chmod 755 filename
    3.  chmod 716 filename
    4.  chmod 666 filename

  13. A quick way to create a file from the command line is:
    1.  cat filename
    2.  cat < filename
    3.  cat > filename
    4.  cat: illegal command

  14. Tell me what the wc command reports in each case:
    1.  cat filename | wc -w ____________________________________
    2.  ls -l | wc -l ___________________________________________
    3.  cat filename | wc -c __________________________________
    4.  head filename | wc _____________________________________

  15. Shell variables are string variables. Tell me three ways to set the variable string1 to a null value.
    1. ________________________________________________
    2. ________________________________________________
    3. ________________________________________________

  16. What do each of the following commands do?
    1.  echo _________________________________________
    2.  tail _________________________________________
    3.  file _________________________________________
    4.  mv ___________________________________________

  17. Which of these is correct?
    1.  variable 1 = 15
    2.  variable2 = 15
    3.  variable3=15
    4.  4var=15

  18. Explain what is wrong with each bad choice in 17.
    1. ________________________________________________
    2. ________________________________________________
    3. ________________________________________________

  19. Which of these forces a mathematical operation?
    1.  variable2 = $variable1 + 15
    2.  variable2=$variable1+15
    3.  variable2='expr $variable1 + 15'
    4.  variable2=`expr $variable1 + 15`

  20. Which of the following lists all filenames starting with a c?
    1.  Ls -a c.*
    2.  Ls -a c???
    3.  Ls -a c*
    4.  Ls -a *c*

  21. Square brackets can enclose sets of allowed characters. What would each command below list?
    1.  Ls -a [a-c]*_______________________________________
    2.  Ls -a ch[1-4]*_____________________________________
    3.  Ls -a *[.c]________________________________________
    4.  Ls -a ch[1234]_____________________________________

  22. grep searches for "regular expressions". Which type of quotes should we use around the regular expression if it contains:
    1.  more than one word _______________________________________________
    2.  special characters we want ignored _______________________________
    3.  special characters we want expanded ______________________________

  23. Which command means to determine the value of variables before executing the rest of the line?
    1.  expr
    2.  resolve
    3.  eval
    4.  doit...just_do_it!

  24. A proper use of the accent grave would be:
    1.  Ls -l `which sh`
    2.  echo `hello, $USER`
    3.  cat > `newfile`
    4.  `Allo, silly English types! `ow you like my accent?