Practice Test #2 Questions - answers at end Important Instructions 1. Read all the instructions and both sides of all pages. 2. Manage your time when answering questions on this test. Answer the questions you know, first. ________________________________________________________________________________ Multiple Choice - 92 Questions This is a practice test containing many practice questions. The real test will contain some questions similar to these. There are probably many more questions in this practice test than there will be time for in the real test. The real test will have approximately one question per minute. The real test may have some questions unlike anything given here. Knowing the concepts behind the questions is necessary; memorizing these specific answers won't help. The answers to this test are in the Answer Key on the last page(s). 1. What is in the file x after this command sequence: echo foo >a ; rm b ; echo bar >>b ; cp a b >x a. nothing - empty file - no data b. bar c. no such file (nonexistent) d. foo e. foo followed by bar 2. Given an existing file of yours named /a/b/x, what is the output of this sequence of three shell commands: echo hi >/a/b/x ; wc /a/b/x >/a/b/x ; cat /a/b/x a. 1 1 3 /a/b/x b. no output on screen c. 1 1 2 /a/b/x d. 1 1 1 /a/b/x e. 0 0 0 /a/b/x 3. What is in file cow after running this bash shell command line? echo one two >cow three a. echo one two b. one two three c. one two cow three d. one two e. nothing - empty file 4. Which of the command lines below can generate a non-empty file? a. head -5 /a/b >/a/b b. cat /a/b /a/b /a/b >/a/b c. wc -l /a/b >/a/b d. sort /a/b >/a/b e. tail /a/b >/a/b 5. How many arguments does the shell pass to this echo command: echo " 1 2 " three ' 4 ' five"6" a. Three arguments. b. Five arguments. c. Nine arguments. d. Four arguments. e. One argument. 6. If file /a contains 40 lines, and file /b contains 60 lines, then how many lines are output by this command: sort /a /b | cat /a | cat /b a. 40 b. 60 c. 100 d. 200 e. 160 7. How many lines are in file out after this bash shell command line? echo hi >dog >cat >out a. 3 b. 1 c. 2 d. no such file (file does not exist) e. 0 (empty file) 8. What is the output of this command sequence: echo foo >file ; echo bar | sort file a. foo followed by bar b. bar c. foo d. an error message e. bar followed by foo 9. Which of the command lines below can generate a non-empty file? a. head -5 file >file b. wc -wc file >file c. cat file file file >file d. sort -r file >file e. tail -3 file >file 10. In an empty directory, how many words are in file out after this bash shell command line? touch a ; ls >out a. 3 b. 2 c. 4 d. 0 (empty file) e. 1 11. If file twenty contains twenty lines, and file thirty contains thirty lines, then how many lines are output by this command: tail thirty | cat twenty a. 20 b. 50 c. 30 d. no output on screen e. 21 12. Which of these command sequences will make file out contain all of the content of file in1 followed by all of the content of file in2? a. cp in1 >out in2 >out b. mv in1 in2 >out c. cat in1 in2 >out d. echo in1 in2 >out e. cp in1 in2 >out 13. What appears on your screen after this bash shell command line? echo hi | wc -c a. 3 b. 0 c. 2 d. 1 e. no output on screen 14. What is the output of this sequence of three shell commands: echo hi >hi ; head hi >hi ; wc hi a. no output on screen b. 1 1 3 hi c. 0 0 0 hi d. 1 1 2 hi e. 2 2 4 hi 15. What is in the file out after this command sequence: echo hi >x ; echo ho >>x ; cp x y >out a. hi followed by ho b. no such file (nonexistent) c. nothing - empty file - no data d. hi e. ho 16. Which of the command lines below can generate a non-empty file? a. sort -r /a/b >/a/b b. grep /a/b /a/b >/a/b c. tail -5 /a/b >/a/b d. cat /a/b >/a/b e. ls -i /a/b >/a/b 17. If file /a contains thirty lines, and file /b contains fifty lines, then how many lines are in file /c after this sequence of shell commands: cat /a /b >/c ; sort /c >/c ; sort /c /a /b >/c a. 30 b. 160 c. 50 d. no lines (empty file) e. 80 18. What is the output on your screen of the following command sequence if run in a directory containing 123 files with names that are all the numbers from 1 to 123 inclusive: glob="*" ; echo "$glob" a. "$glob" b. $glob c. the file names 1 through 123, surrounded by quotes d. * e. the file names 1 through 123 19. What appears on your screen after this bash shell command line? echo hi >ls ; cat ls > wc a. 1 1 3 b. 1 1 2 c. no output on screen d. ls e. hi 20. How many arguments are passed to the command by the shell on this command line: cow cow a. 4 b. 5 c. 7 d. 3 e. 6 21. What appears on your screen after this bash shell command line? echo hi >out | wc -c a. 0 b. 2 c. 3 d. no output on screen e. 1 22. In an empty directory, how many words are in file out after this bash shell command line? touch 1 2 3 2 1 ; ls >out a. 5 b. 0 (empty file) c. 3 d. 4 e. 6 23. How many arguments are passed to the command by the shell on this command line: pig pig pig a. 8 b. 9 c. 6 d. 5 e. 7 24. Which of the following is true, given this long directory listing from ls: drwxr-x--x 256 ian user 512 May 30 12:35 dir a. The number 256 is the size of this directory. b. The number 512 is the size of this directory. c. The number 256 is the octal permissions of this directory. d. The number 256 is the inode number of this directory. e. The number 512 is the count of links (names) this directory has. 25. Which of the following statements is true about this shell command line: >/a/b/c cat /a/b/d a. The command /a/b/c sees two arguments. b. The command /a/b/c sees only one argument c. The command cat sees two arguments. d. The command is always invalid. e. The command cat sees only one argument. 26. Which of these command sequences will make file foo contain all of the content of file a followed by all of the content of file b? a. cp a >foo ; cp b >>foo b. mv a b >foo c. cp a b >foo d. cat a >foo ; cat b >>foo e. echo a b >foo 27. If file x contains ten lines, and file y contains twenty lines, then how many lines are in file cat after this sequence of bash shell commands: sort x y >z ; tail -5 y >y ; sort x y z >cat a. 60 b. no lines (empty file) c. 45 d. 40 e. 50 28. What appears on your screen after this bash shell command line? mkdir foo ; rmdir foo | wc -c a. 0 b. 3 c. no output on screen d. 1 e. 4 29. Which of the following VI/VIM key sequences will move the entire line on which the cursor resides to after the line that follows it (i.e. it would move line 5 to be line 6 and line 6 would become line 5)? a. ddp b. DDP c. :dp d. DDp e. ddP 30. Select the correct bash shell order of command line processing: a. quotes, redirection, variables, globs b. quotes, variables, redirection, globs c. quotes, globs, variables, redirection d. redirection, quotes, globs, variables e. quotes, variables, globs, redirection 31. How many lines are in the file out after this command sequence: echo hi >x ; echo ho >>x ; cat x x x >out a. 3 b. 6 c. 1 d. nothing - empty file - no data e. 2 32. What is in the file named file after this command sequence: echo a >c ; echo b >>c ; mv c d >file a. nothing - file is empty - no data b. a followed by b c. b d. no such file (nonexistent file) e. a 33. What is in file out after running this bash shell command line? echo 2 3 >out 3 0 a. nothing - empty file b. 2 3 0 c. 2 3 >out 3 0 d. 2 3 3 0 e. 2 3 34. What is true about this bash shell command line? date >ls ; ls -ls ls >wc a. The shell finds and executes three different commands. b. The ls command is executed more than once. c. The wc command counts the output of the ls command. d. The ls command receives the output of date on standard input. e. The file wc has one line in it. 35. If your PATH variable contains /bin:/usr/bin, what is the output of this bash shell command line? echo '$PATH' a. /bin b. '$PATH' c. /bin:/usr/bin d. '/bin' e. $PATH 36. How many arguments are passed to the command by the shell on this command line: bat bat bat a. 5 b. 6 c. 7 d. 4 e. 3 37. Which of these command sequences will make file3 contain all of the content of file1 followed by all of the content of file2? a. mv file1 file2 >file3 b. echo file1 file2 >file3 c. cp file1 >file3 file2 >file3 d. cp file1 file2 >file3 e. cat file1 file2 >file3 38. How many arguments does the shell pass to this echo command: echo " 1 2 "three ' 4 ' five"6" a. Five arguments. b. One argument. c. Nine arguments. d. Four arguments. e. Three arguments. 39. What text is output by this bash shell command sequence: echo dog >out ; echo cat | sort out a. dog b. cat followed by dog c. out d. dog followed by cat e. cat 40. What is in file out after running this bash shell command line? echo a >out b c a. a b. a b c c. echo a d. b c e. nothing - empty file 41. How many arguments does the shell pass to this echo command: echo 'And it's not hard, it's just logical.' a. Six arguments. b. Five arguments. c. Four arguments. d. Three arguments. e. Seven arguments. 42. If file ten contains ten lines, and file twenty contains twenty lines, then how many lines are output by this command: cat twenty | sort ten a. 10 b. 20 c. no output on screen d. 30 e. 60 43. Which of the following is true, given this long directory listing from ls: drwxr-x--x 456 ian user 123 May 30 12:35 dir a. The number 123 is the size in bytes of this directory. b. The number 456 is the octal permissions of this directory. c. The number 123 is the count of links (names) this directory has. d. The number 456 is the inode number of this directory. e. The number 456 is the size of this directory. 44. In an empty directory, what is the shell output of these three commands: touch .1 .2 .3 11 12 ; b='.1* .2*' ; echo '$b' a. $b b. 11 .1 12 .2 c. '.1* .2*' d. .1* .2* e. .1 .2 45. What appears on your screen after this sequence of commands: echo one >x ; cp x y ; echo two >>y ; sort x >y ; cat y a. one b. no output on screen c. one followed by two d. two followed by one e. two 46. Which one of the following commands will leave file1 non-empty? a. sort file1 > file1 b. tail file1 > file1 c. wc file1 > file1 d. cat file1 > file1 e. head file1 > file1 47. What appears on your screen after this bash shell command line? echo hi >a ; cat a | wc -c a. 2 b. 4 c. 1 d. no output on screen e. 3 48. If I am in my home directory named /home/ian and mt is an empty sub- directory, what is true after this command line: who >../ian/cat ; cp ./mt/../cat ./mt/../dog a. the command fails because the path ./mt/../cat does not exist b. the directory mt now contains two files c. the directory mt is still empty d. there is a second copy of the file named who in the file dog e. the directory mt now has a file named dog in it 49. How many command arguments does the shell pass to this echo command: echo 'It's a bird! No! It's a plane!' a. Five arguments. b. Three arguments. c. One argument. d. Two arguments. e. Four arguments. 50. If your terminal type is xterm, what is the output of this bash shell command line? echo '$TERM' a. '$TERM' b. no output on screen c. xterm d. 'xterm' e. $TERM 51. In an empty directory, what is the length of the longest file name created by the following shell two-command sequence: var='a ab abc abcd abcde' ; touch "$var" a. 15 characters b. 5 characters c. 19 characters d. 4 characters e. 3 characters 52. If file /a contains thirty lines, and file /b contains fifty lines, then how many lines are output by this command: cat /a | sort /b a. 50 b. no lines (empty file) c. 30 d. 20 e. 80 53. In an empty directory, what appears on your screen after this bash command line? touch a ; ls | wc -l a. no output on screen b. 3 c. 0 d. 2 e. 1 54. How many command arguments does the shell pass to this echo command: echo 'It's a bird! It's a plane!' a. Four arguments. b. Three arguments. c. Five arguments. d. Two arguments. e. One argument. 55. What appears on your screen after this bash shell command line? echo hi >a ; ls a > wc a. 1 1 2 b. 2 c. 1 1 3 d. 3 e. no output on screen 56. Which of the command lines below can generate a non-empty file? a. ls -ls file >file b. sort -r file file >file c. head -1 file >file d. grep pattern file >file e. touch file >file 57. Which of the following is true, given this long directory listing from ls: drwxr-x--x 123 ian user 456 May 30 12:35 dir a. The number 456 is the size of this directory. b. The number 123 is the inode number of this directory. c. The number 456 is the count of links (names) this directory has. d. The number 123 is the size of this directory. e. The number 123 is the octal permissions of this directory. 58. What appears on your screen after this bash shell command line? echo hi >a ; ls a | wc -c a. 4 b. no output on screen c. 1 d. 3 e. 2 59. How many arguments does the shell pass to this echo command: echo ' one two ' three ' four ' 5'6' a. Five arguments. b. Four arguments. c. Nine arguments. d. Six arguments. e. One argument. 60. What is the output of this sequence of three shell commands: echo hi >wc ; ls wc >wc ; wc wc a. 2 2 4 wc b. 1 1 2 wc c. 1 1 3 wc d. 0 0 0 wc e. no output on screen 61. What appears on your screen after this bash shell command line? echo xx >z ; ls z > wc a. 3 b. 1 1 2 c. 2 d. 1 1 3 e. no output on screen 62. Given an existing file of yours named wc, what is the output of this sequence of three shell commands: echo hi >wc ; sort wc >wc ; cat wc a. 2 2 4 wc b. no output on screen c. 0 0 0 wc d. 1 1 2 wc e. 1 1 3 wc 63. What is the output of this bash shell command line in an empty directory? echo '$SHELL' a. no output on screen b. /bin/bash c. $SHELL d. '$SHELL' e. '/bin/bash' 64. Given an existing file of yours named /a/x, what is the output of this sequence of three shell commands: echo hi >/a/x ; sort /a/x >/a/x ; wc /a/x a. 1 1 2 /a/x b. 2 2 4 /a/x c. 0 0 0 /a/x d. no output on screen e. 1 1 3 /a/x 65. In an empty directory, what is the shell output of these three commands: touch xx .x xy .y xz ; a='x* y*' ; echo "$a" a. *x *y b. xx xy xz y* c. x* y* d. $a e. xx xy 66. What text is output by this bash shell command sequence: echo cow >foo ; echo dog | head -1 foo a. cow b. cow followed by dog c. dog d. foo e. dog followed by cow 67. What is the output on your screen of the following sequence of commands: echo hi >wc ; wc wc >hi ; cat hi a. 1 1 2 wc b. 0 0 0 wc c. hi d. no output on screen e. 1 1 3 wc 68. In an empty directory, what is the length of the longest file name created by the following sequence: var='a ab abc abcd abcde' ; touch '$var' a. 19 characters b. 4 characters c. 5 characters d. 15 characters e. 3 characters 69. In an empty directory, how many arguments are passed to the cat command in this bash command line? date >a1 ; touch a2 ba ca ; cat a* a. 3 b. 2 c. 1 d. 4 e. none 70. In an empty directory, what appears on your screen after this bash command line? touch a ; ls >wc -l a. 2 b. 1 c. no output on screen d. 3 e. 0 71. Which of the following statements is true about this shell command line: >bar zoom bar haven a. The command zoom sees two arguments. b. The command bar sees three arguments. c. Error: The command name is missing from the command line. d. The command zoom sees three arguments. e. The command bar sees only two arguments 72. What appears on your screen after this bash shell command line? echo hi >out ; wc -c out a. 2 out b. 5 out c. 4 out d. no output on screen e. 3 out 73. How many arguments does the shell pass to this echo command: echo " one '2 three' 4 "five 6 ' 7 "8 ' >out a. Three arguments. b. Six arguments. c. Four arguments. d. Five arguments. e. Two arguments. 74. Which of the command lines below can generate a non-empty file? a. sort -r /out >/out b. ls /out >/out c. grep -v /out /out >/out d. tail -5 /out >/out e. head /out 75. What is the output of this command sequence: echo bat >one ; echo sky | head -2 one a. bat followed by sky b. bat c. an error message d. sky followed by bat e. sky 76. What is the output on your screen of the following sequence of commands: echo wc >wc ; wc wc >wc ; cat wc a. 0 0 0 wc b. no output on screen c. wc d. 1 1 3 wc e. 1 1 2 wc 77. What is the output on your screen of this command sequence: echo dog >one ; echo cow | head -2 one a. an error message b. dog c. cow d. dog followed by cow e. cow followed by dog 78. What appears on your screen after this bash shell command line? echo hi >a ; echo a | wc -c a. 4 b. 1 c. 2 d. 3 e. no output on screen 79. What is in the file bar after this command sequence: echo hi >x ; echo ho >x ; mv x y >bar a. nothing - empty file - no data b. hi followed by ho c. no such file (nonexistent) d. hi e. ho 80. How many arguments does the shell pass to this echo command: echo "cow "y " bat 'man x' " pig'a "hop' a b a. Eleven arguments. b. Five arguments. c. Six arguments. d. Four arguments. e. Seven arguments. 81. How many arguments are passed to the command by the shell on this command line: bar bar bar a. 7 b. 4 c. 6 d. 3 e. 5 82. If file a contains twenty lines, and file b contains thirty lines, then how many lines are in file out after this sequence of bash shell commands: cat a b >c ; head c >c ; sort a b c >out a. 60 b. no lines (empty file) c. 50 d. 100 e. 30 83. How many lines are in the file bar after this command sequence: echo hi >x ; echo ho >>x ; cat x x >bar a. 2 b. 6 c. 1 d. 4 e. nothing - empty file - no data 84. In an empty directory, how many arguments are passed to the rm command in this bash command line? date >a1 ; touch a2 ba ca >all ; rm a* a. 3 b. 4 c. 2 d. 1 e. none 85. How many lines are in file out after this bash shell command line? echo hi >dog >out >cat a. 1 b. 3 c. 0 (empty file) d. no such file (file does not exist) e. 2 86. If file /a contains 20 lines, and file /b contains 30 lines, then how many lines are in file /c after this sequence of shell commands: sort /a /b >/c ; cat /a >>/b ; sort /c /b /a >/c a. 50 b. no lines (empty file) c. 80 d. 120 e. 70 87. What appears on your screen after this bash shell command line? echo hi >a ; cp a b | wc -c a. 0 b. no output on screen c. 3 d. 2 e. 1 88. In an empty directory, what is the length of the longest file name created by the following two-command sequence: var='a ab abc abcd abcde' ; touch $var a. 3 characters b. 19 characters c. 5 characters d. 15 characters e. 4 characters 89. In an empty directory, how many words are in file cow after this bash shell command line? touch dog dog cat ; ls >cow a. 2 b. 4 c. 0 (empty file) d. 1 e. 3 90. What is the output of this sequence of three shell commands: echo x >abc ; ls >abc abc ; wc abc a. no output on screen b. 1 1 4 abc c. 1 1 3 abc d. 0 0 0 abc e. 1 1 2 abc 91. If I am in my home directory named /home/alleni and empty is an empty sub- directory, what is true after this command line: date >./cat ; mv empty/../cat ../alleni/dog a. the directory empty now contains only a file named dog b. the command fails because the path ../alleni/dog does not exist c. there is a second copy of the file cat in the file named dog d. the directory empty/.. now has a file named dog in it e. the command fails because the path empty/../cat does not exist 92. How many arguments and options are there to the command: wc -l