Test #1 Multiple Choice Important Instructions 1. Read all the instructions and both sides (back and front) of all pages. 2. Manage your time when answering questions on this test. Answer the questions you know, first. _________________________________________________________________ Multiple Choice - 58 Questions - 10 of 15% (Office use only: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58) 1. If /home/idallen is a directory name, which of the following pathnames always leads to the same directory? *a. /home/./../home/idallen b. /home/../home/../idallen c. ./home/idallen d. ../home/idallen e. /home/./home/../idallen 2. If my current working directory is /usr, and my home directory is /home/me, which of the of the following commands copies the Unix password file into my home directory under the name foo? *a. cp ../etc/passwd ../home/me/foo b. cp ../usr/../etc/passwd ./home/me/foo c. cp ../usr/./etc/passwd ./home/me/foo d. cp ../usr/passwd ../home/foo e. cp ../usr/passwd ./me/foo 3. If my current directory is /usr, which of these pathnames is equivalent to the file name /bin/ls? *a. ../bin/ls b. ../bin/ls/. c. /bin/../ls d. ././bin/ls e. /root/bin/ls 4. If file nine contains nine lines, each of which is the one- digit line number of the line in the file (1 through 9), what is the output on your screen of this command: sort -r nine nine | tail -5 | head -1 *a. 3 b. 7 c. 5 5 d. 7 7 e. 1 1 5. If file foo contains nine lines, each of which is the one- digit line number of the line in the file (1 through 9), what is the output on your screen of this command: cat foo foo foo | sort -r | head -4 | tail -1 *a. 8 b. 7 c. 6 d. 5 e. 9 6. Which Unix command sequence deletes a directory and everything inside it? *a. rm -r dir b. mv -r dir c. erase -r dir d. rmdir -r dir e. delete -r dir 7. How can you ask the bash (Linux) shell to complete commands or file names for you? *a. You can type the first part of the command or file name and press the TAB key. b. You can type the first part of the command or file name and press the ALT key. c. Type [CONTROL]-[ALT]-[DEL] and the shell will present a menu of commands. d. Type [CONTROL]-[D] and the shell will present a menu of commands. e. Type [ALT]-[F2] the shell will present a menu of commands. 8. If you type the command: wc which of the following key sequences will send an EOF, generate output, then take you back to the command prompt? *a. [CTRL-D] b. [CTRL-C] c. [CTRL-L] d. [CTRL-U] e. [CTRL-R] 9. If you type the command: sort which of the following key sequences will interrupt it (no output) and take you immediately back to the command prompt? *a. [CTRL-C] b. [CTRL-D] c. [CTRL-L] d. [CTRL-U] e. [CTRL-R] 10. Which of the command lines below will generate a non-empty file? *a. ls -l file >file b. sort -r file file >file c. grep pattern file >file d. touch file >file e. head -1 file >file 11. Which command line below does not show any lines from inside the file bat? *a. ls bat b. head bat c. tail bat d. cat bat e. sort bat 12. How many arguments does the shell pass to this echo command: echo " one '2 three' "4 five 6 ' 7 "8 ' >out *a. Four arguments. b. Five arguments. c. Six arguments. d. Two arguments. e. Three arguments. 13. How many command arguments does the shell pass to this echo command: echo 'It's "lots" isn't it? I won't be guessing. *a. Five arguments. b. Four arguments. c. Three arguments. d. Two arguments. e. Six arguments. 14. How many command arguments does the shell pass to this echo command: echo four five *a. Three arguments. b. Four arguments. c. Five arguments. d. Six arguments. e. Two arguments. 15. Which of the following is true, given this long directory listing from ls: drwxr-x--x 512 ian user 123 May 30 12:35 dir *a. The number 123 is the size in bytes of this directory. b. The number 123 is the count of links (names) this directory has. c. The number 512 is the inode number of this directory. d. The number 512 is the octal permissions of this directory. e. The number 512 is the size of this directory. 16. What is the output on your screen of this bash shell command line in an empty directory? echo * *a. * b. an error message from echo saying * does not exist c. no output on screen d. . .. e. . 17. What is the output on your screen of this bash shell command line in an empty directory? ls * *a. an error message from ls saying * does not exist b. no output on screen c. * d. . .. e. . 18. What appears on your screen after this bash shell command line? echo 123 | wc -c *a. 4 b. 3 c. 2 d. 1 e. no output on screen 19. What appears on your screen after this bash shell command line? echo hi >a ; mv a b | wc -c *a. 0 b. 1 c. 2 d. 3 e. no output on screen 20. What appears on your screen after this bash shell command line? echo hi >out | sort -r *a. no output on screen b. hi c. out d. ih e. tou 21. What appears on your screen after this bash shell command line? echo date >ls ; cat ls > wc *a. no output on screen b. 1 1 4 c. 1 1 5 d. ls e. date 22. Which command line displays the contents of the Unix passwd file one page at a time? *a. less /etc/passwd b. less | /etc/passwd c. /etc/passwd >less d. /etc/passwd | less e. cat /etc/passwd >less 23. Which command below removes only this four-character file name containing a special character (and no others): 123* *a. rm 123\* b. rm 123/* c. rm 123\\* d. rm 123//* e. rm 123* 24. What appears on your screen after this sequence of commands: echo aaa >a ; cp a b ; echo bbb >>b ; cat a >b ; cat b *a. aaa b. aaa followed by bbb c. bbb d. bbb followed by aaa e. no output on screen 25. Which command line lists all possible utilities available for sorting files? *a. man -k sort b. man sort c. grep sort /etc/passwd d. grep /etc/passwd sort e. man | grep sort 26. Which command line lists all possible utilities available for compiling programs? *a. apropos compile b. man compile c. grep compile /etc/* d. grep /etc/* compile e. man * | grep compile 27. In an empty directory, what is the length of the longest file name created by the following shell two-command sequence: x='a ab abc abcd' ; touch "$x" *a. 13 characters b. 10 characters c. 4 characters d. 3 characters e. 2 characters 28. In an empty directory, what is the length of the longest file name created by the following two-command sequence: x='a ab abc abcd' ; touch $x *a. 4 characters b. 3 characters c. 2 characters d. 13 characters e. 10 characters 29. In an empty directory, what is the length of the longest file name created by the following sequence: x='a ab abc abcd' ; touch '$x' *a. 2 characters b. 3 characters c. 4 characters d. 13 characters e. 10 characters 30. Which of these statements is true? *a. If /x is an empty directory, cat /x/* produces an error message. b. If /y is an empty directory, echo /y/* produces an error message. c. Only single quotes are strong enough to stop shell glob (wildcard) patterns from expanding. d. Only double quotes are strong enough to stop shell glob (wildcard) patterns from expanding. e. Only backslashes are strong enough to stop shell glob (wildcard) patterns from expanding. 31. How many lines are in the file bar after this command sequence: echo hi >x ; echo ho >>x ; cat x x >bar *a. 4 b. 6 c. 2 d. 1 e. nothing - empty file - no data 32. How many arguments and options are there to the command: wc -wc /sort *a. Two command line arguments, one of which contains two bundled options. b. Two arguments, one of which is a single option and the other is a pathname. c. A three-letter file name and a /sort switch option argument. d. Two arguments, no options. e. Two options, no arguments. 33. In an empty directory, how many arguments are passed to the sort command in this bash command line? who >a1 ; touch a a2 ba ca >all ; sort a* *a. 4 b. 3 c. 2 d. 1 e. none 34. Which command sequence below outputs only lines 11-15 of the 16-line file named foo? *a. head -15 foo | tail -5 b. tail -15 foo | head -11 c. head -16 foo | tail -5 foo d. head -10 foo | tail -15 foo e. tail -10 foo | head -16 foo 35. If directory /dir contains only these three four-character file names: .123, .124, .???, then what is the output on your screen of the following command line: echo /dir/???? *a. /dir/???? b. /dir/.123 /dir/.124 /dir/.??? c. /dir/.123 /dir/.124 d. echo: /dir/????: No such file or directory e. no output 36. Which of these command sequences will make file bar contain all of the content of file one followed by all of the content of file two? *a. cat one >bar ; cat two >>bar b. cp one >bar ; cp two >>bar c. cp one two >bar d. mv one two >bar e. echo one two >bar 37. If file twenty contains twenty lines, and file thirty contains thirty lines, then how many lines are output by this command: head twenty | sort thirty *a. 30 b. 10 c. 20 d. 40 e. 50 38. If file x contains ten lines, and file y contains twenty lines, then how many lines are in file z after this sequence of bash shell commands: sort x y >z ; head -5 y >y ; sort x y z >z *a. 10 b. 60 c. 50 d. 45 e. 15 39. In an empty directory, how many words are in file cow after this bash shell command line? touch dog pig cat ; ls >cow *a. 4 b. 3 c. 2 d. 1 e. no output (empty file) 40. What is the output on your screen of this successful command sequence? cd /tmp ; mkdir one ; mkdir two ; pwd *a. /tmp b. /tmp/one c. /tmp/two d. /tmp/one/two e. /two 41. Which of the following shell command lines displays only the names in the current directory that are exactly three lower- case letters long? *a. echo [a-z][a-z][a-z] b. echo [a,z][a,z][a,z] c. echo [az][az][az] d. echo *a-z*a-z*a-z* e. echo ??? 42. Which of the following shell command lines displays only the names in the current directory that are exactly three digits long? *a. echo [0-9][0-9][0-9] b. echo [1-3][1-3][1-3] c. echo [3][3][3] d. echo [?][?][?] e. echo ??? 43. Which of the following statements is true about this shell command line: >four one echo three *a. The command one gets exactly two arguments. b. The command one gets exactly three arguments. c. The command echo gets exactly one argument d. The command echo gets exactly two arguments e. The command >four gets exactly three arguments. 44. What is in file out after running this bash shell command line? echo 8 1 >out 2 9 *a. 8 1 2 9 b. 8 1 c. 8 1 0 d. 8 1 >out 2 9 e. no output (empty file) 45. What is the output on your screen of this bash shell command line in an empty directory? touch foo ; echo bar | ls *a. foo b. bar c. foo followed by bar d. bar followed by foo e. no output on screen 46. What is the output on your screen of this bash shell command line in an empty directory? touch .bar ; echo foo | ls *a. no output on screen b. foo c. .bar d. foo followed by .bar e. .bar followed by foo 47. In an empty directory, what is the output on your screen of these three commands: touch .1 .2 .3 11 12 ; b='.1* .2*' ; echo '$b' *a. $b b. .1* .2* c. '.1* .2*' d. .1 .2 e. 11 .1 12 .2 48. In an empty directory, what is the output on your screen of these three commands: touch .x .y xx xy xz ; a='x* y*' ; echo "$a" *a. x* y* b. xx xy xz c. xx xy xz y* d. $a e. .x xx xy xz .y xy 49. In an empty directory, what is the output on your screen of these three commands: touch .a .b aa bb zz ; z='*' ; echo $z *a. aa bb zz b. $z c. zz d. * e. no output on screen 50. If foo is a sub-directory that contains only the file single, what happens after this command: mv foo/single foo/././cat *a. the directory foo now contains only a file named cat b. the directory foo is now empty c. there is a second copy of the file single in the file named cat d. the command fails because the name cat does not exist e. the command fails because the name foo/././cat does not exist 51. What command shows all the lines in file foo that contain the string bar? *a. grep bar foo b. grep foo bar c. cat foo > grep bar d. grep cat foo bar e. grep bar >foo 52. In the output of command ls -a, the output pathname that is a single dot (.) signifies what? *a. The current directory. b. A name that is hidden. c. The parent directory. d. A current file. e. A name with an unprintable character. 53. In the output of command ls -a, the output pathname that is a double dot (..) signifies what? *a. The parent directory. b. A file or directory with double links. c. A hidden file. d. The current directory. e. The root directory. 54. In the output of command ls -a, a dot that begins a pathname signifies what? *a. A name that is hidden. b. The parent directory. c. The current directory. d. A current file. e. A name with an unprintable character. 55. If your PATH variable contains /bin:/usr/bin, what is the output of this bash shell command line? echo "$PATH" *a. /bin:/usr/bin b. $PATH c. "$PATH" d. /bin e. "/bin" 56. What is true after this bash shell command line? who >cat ; ls -ls cat >head *a. The file head contains one line. b. The head command reads the output of the ls command. c. The ls command reads the output of the cat command on standard input. d. The cat command receives the output of who on standard input. e. The shell finds and executes more than two commands. 57. What can you do to get back (redo) the last command you typed to the bash (Linux) shell? *a. Use the "UpArrow" key. b. Use the "PageUp" key. c. Type [ALT]-[F2] d. Type [CONTROL]-[ALT]-[UP] e. Type [CONTROL]-[BACKSPACE] 58. Select the correct bash shell order of command line processing: *a. quotes, redirection, variables, GLOBs b. quotes, variables, redirection, GLOBs c. quotes, variables, GLOBs, redirection d. quotes, GLOBs, variables, redirection e. redirection, quotes, GLOBs, variables Answer Key - CST8129 - Ian Allen - Fall 2005 - CST8129 Unix Test #1 - 15% Office use only: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 1. a 53. a 2. a 54. a 3. a 55. a 4. a 56. a 5. a 57. a 6. a 58. a 7. a 8. a Count of a: 58 100% 9. a 10. a With 5 choices: 58 11. a 12. a Macro .cmd split with indent: 15 13. a 14. a 15. a 16. a 17. a 18. a 19. a 20. a 21. a 22. a 23. a 24. a 25. a 26. a 27. a 28. a 29. a 30. a 31. a 32. a 33. a 34. a 35. a 36. a 37. a 38. a 39. a 40. a 41. a 42. a 43. a 44. a 45. a 46. a 47. a 48. a 49. a 50. a 51. a 52. a