Practice Test #1 Questions - answers at end - DO NOT PRINT THIS VERSION Print the PDF file instead. 176 Questions Important Instructions 1. Read all the instructions and both sides (back and front) of all pages. 2. Answer the questions you know, first. One Answer Only per question. 3. Manage your time when answering questions on this test! ________________________________________________________________________________ Multiple Choice - 176 Questions - 0 of 0% 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. If /bin/bash is a file name, which pathname always leads to the same file? a. /bin/../bin/bash c. /bin/bash/. e. ./bin/bash b. /bin/../bash d. /bin/bin/../bash 2. If my current working directory is /home, and my home directory is /home/me, which of the following commands copies the Unix password file into my home directory under the name foo? a. cp ../etc/passwd ../me/foo b. cp ../../etc/passwd /me/foo c. cp ../etc/passwd ./me/foo d. cp ./me/../etc/passwd ../home/me/foo e. cp ../home/me/../etc/passwd ./me/./foo 3. If you type the command sort which of the following key sequences will send an EOF and take you immediately back to the command prompt? a. [CTRL-R] c. [CTRL-U] e. [CTRL-D] b. [CTRL-C] d. [CTRL-L] 4. In an empty directory, how many words are in file pig after this command line? touch pig pig ; ls >pig a. 1 d. 2 b. 4 e. empty file (no data) c. 3 5. 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. 4 d. 6 b. no output (empty file) e. 3 c. 5 6. In the output of the command ls -a, the one-character name . signifies what? a. A name that is hidden. b. A current file. c. The current directory. d. A name with an unprintable character. e. The parent directory. 7. What is the output on your screen of this command sequence: echo dog >one ; echo cow | head -2 one a. cow d. dog followed by cow b. an error message e. dog c. cow followed by dog 8. What appears on your screen after this bash shell command line? echo hi >out | wc -c a. no output on screen d. 0 b. 1 e. 2 c. 3 9. If my current working directory is /home, 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 me/../../etc/passwd me/foo b. cp ../etc/passwd ../me/foo c. cp ../../etc/passwd /me/foo d. cp ../home/me/../etc/passwd ./me/./foo e. cp ./me/../etc/passwd ../home/me/foo 10. 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. no such file (nonexistent) c. hi d. ho e. hi followed by ho 11. In the output of the command ls -a, a dot that begins a name signifies what? a. A name that is hidden. b. A current file. c. A name with an unprintable character. d. The current directory. e. The parent directory. 12. If file /a contains 30 lines, and file /b contains 50 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. 160 d. 30 b. 80 e. no lines (empty file) c. 50 13. Which command line finds all possible utilities available for compiling programs? a. grep /etc/* compile d. grep compile /etc/* b. man * | grep compile e. man -k compile c. man compile 14. If I am in my home directory named /home/me and x is an empty sub- directory, what is true after this command line: touch ./x/fil ; mv x/./fil x/../../me/./y a. the directory x now contains only a file named y b. there is a second copy of the file fil in the file named y c. the directory x is still empty d. the command fails because the path x/../../me does not exist e. the command fails because the path x/./fil does not exist 15. What is the output on your screen of this shell command line in an empty directory? touch .a .b .c ; echo .* a. . .. .a .b .c b. no output on screen c. an error message from echo saying .* does not exist d. .a .b .c e. .* 16. What appears on your screen after this bash shell command line? echo hi | wc a. 1 1 2 d. 1 1 3 b. 1 2 1 e. no output on screen c. 2 1 1 17. 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 | sort -r | head -4 | tail -1 a. 9 c. 6 e. 5 b. 7 d. 8 18. What is the output on your screen of this shell command line in an empty directory? ls * a. * b. . .. c. . d. no output on screen e. an error message from ls saying * does not exist 19. 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. 1 c. 6 d. nothing - empty file - no data e. 4 20. If file /a/b contains 99 lines, each of which is the two-digit line number of the line in the file (01 through 99), what is the output on your screen of this command: sort /a/b /a/b | tail -4 | head -1 a. 96 c. 04 04 e. 01 01 b. 98 d. 96 96 21. Which command line displays all the non-hidden names in the current directory that contain the letter x (and no others)? a. echo [*x*] c. echo *x e. echo *x* b. echo ?x? d. echo x* 22. If /etc/passwd is a file name, which pathname always leads to the same file? a. /etc/passwd/. d. /../etc/passwd b. /etc/../../passwd e. ./etc/passwd c. /etc/passwd/../.. 23. What is the output on your screen of this successful command sequence? cd /tmp ; mkdir foo ; mkdir bar ; pwd a. /tmp/foo/bar c. /tmp e. /tmp/bar b. /bar d. /tmp/foo 24. What is the output on your screen of the following sequence of commands: echo hi >wc ; wc wc >hi ; cat hi a. no output on screen d. hi b. 1 1 2 wc e. 1 1 3 wc c. 0 0 0 wc 25. What would you see if you typed this command: cat /users a. The contents of your subdirectory named users b. The contents of the file users located in the root directory c. The contents of the file users located in the parent directory d. The contents of your directory named users e. The contents of the file users located in your home directory 26. If I am in my home directory named /home/myhome and dir is an empty sub- directory, what is true after this command line: touch new ; mv ./dir/../new ../myhome/old a. the directory dir now contains only a file named old b. the command fails because the path ../myhome/old does not exist c. the parent directory of dir now has a file named old in it d. the command fails because the path ./dir/../new does not exist e. there is a second copy of the file new in the file named old 27. How many lines are in file out after this command line? echo hi >dog >out >cat a. 2 b. no such file (file does not exist) c. nothing - empty file - no data d. 1 e. 3 28. Which command pipeline outputs the count of the number of pathnames (including all subdirectories) that lie under the /etc directory? a. ls /etc | wc c. ls /etc ; wc e. man /etc ; wc b. find /etc | wc d. dir /etc | count 29. Which of these statements is true? a. To indicate End-of-File (no more input) to a program, type [CONTROL]-[D]. b. To erase an entire line of typing, type [ALT]-[DELETE]. c. Command apropos is an exact synonym for command man. d. The file command creates a new, empty file in the current directory e. To interrupt a Unix process from the keyboard, type [CONTROL]-[D]. 30. Given an existing file of yours named /a/b/x, what is the output on your screen 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 2 /a/b/x d. no output on screen b. 1 1 3 /a/b/x e. 0 0 0 /a/b/x c. 1 1 1 /a/b/x 31. What is in the file out after this command sequence: echo hi >x ; echo ho >>x ; cp x y >out a. ho b. nothing - empty file - no data c. hi d. hi followed by ho e. no such file (nonexistent) 32. If file /a contains 30 lines, and file /b contains 50 lines, then how many lines are output on your screen by this command: cat /a | sort /b a. 30 d. no lines (empty file) b. 80 e. 50 c. 20 33. 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 cat sees two arguments. c. The command is always invalid. d. The command cat sees only one argument. e. The command /a/b/c sees only one argument 34. What is the output on your screen of this shell command line in an empty directory? touch 1 2 3 .a .ab .abc ; echo [.]* a. an error message from echo saying [.]* does not exist b. [.]* c. no output on screen d. .a .ab .abc e. . .. .a .ab .abc 35. What appears on your screen after this bash shell command line? mkdir foo ; rmdir foo | wc -c a. 1 d. 3 b. no output on screen e. 0 c. 4 36. What is in the file cow after this command line: echo a >a ; echo b >b ; mv a b >cow a. a followed by b b. no such file (nonexistent) c. a d. nothing - empty file - no data e. b 37. If /bin/bash is a file name, which pathname always leads to the same file? a. /bin/../bash c. /../bin/./bash e. ./../bin/bash b. /bin/bash/. d. /bin/bin/../bash 38. 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 nine nine | tail -5 | head -1 a. 7 c. 1 1 e. 5 5 b. 1 d. 9 39. How many command arguments does the shell pass to this echo command: echo 1 2 3 4 >5 a. 6 c. 5 e. 3 b. 4 d. 7 40. What is in the file x after this command sequence: echo foo >a ; rm b ; echo bar >>b ; cp a b >x a. foo followed by bar b. bar c. foo d. no such file (nonexistent) e. nothing - empty file - no data 41. If directory cow contains only these four three-character file names: .AA, .A1, .BB, .B., then what is the output on your screen of this command line: echo cow/* a. cow/.B. b. no output on screen c. cow/.AA cow/.A1 cow/.BB cow/.B. d. cow/* e. cow/.AA cow/.A1 cow/.BB 42. If cow is a sub-directory that contains only the file dog, what happens after this command: mv cow/dog cow/././cat a. the directory cow is now empty b. the command fails because the name cat does not exist c. there is a second copy of the file dog in the file named cat d. the command fails because the name cow/././cat does not exist e. the directory cow now contains only a file named cat 43. What is in file out after running this bash shell command line? echo a >out b c a. b c d. a b. no output on screen e. a b c c. echo a 44. What command shows all the lines in file /etc/group that contain the string idallen? a. grep idallen /etc/group d. cat /etc/group | wc idallen b. cat /etc/group ; grep idallen e. grep idallen ; /etc/group c. grep /etc/group idallen 45. What is in the file named file after this command sequence: echo a >c ; echo b >>c ; mv c d >file a. a followed by b b. b c. nothing - file is empty - no data d. no such file (nonexistent file) e. a 46. Which of the following shell command lines displays all the names in the current directory that are exactly three digits long (and no others)? a. echo ??? d. echo [0-9][0-9][0-9] b. echo [3][3][3] e. echo [1-3][1-3][1-3] c. echo [?][?][?] 47. If file /a contains 40 lines, and file /b contains 60 lines, then how many lines are output on your screen by this command: sort /a /b | cat /a | cat /b a. 40 c. 200 e. 160 b. 100 d. 60 48. How can you ask the bash (Linux) shell to complete commands or file names for you? a. Type [CONTROL]-[ALT]-[DEL] and the shell will present a menu of commands. b. You can type the first part of the command or file name and press the TAB key. c. Type [CONTROL]-[D] and the shell will present a menu of commands. d. Type [ALT]-[F2] the shell will present a menu of commands. e. You can type the first part of the command or file name and press the ALT key. 49. 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 nine nine nine | tail -3 | head -1 a. 1 1 1 c. 7 7 7 e. 7 b. 9 d. 8 50. If file ten contains 10 lines, and file twenty contains 20 lines, then how many lines are output on your screen by this command: cat twenty | sort ten a. no lines (no output) d. 60 b. 20 e. 30 c. 10 51. What is the output on your screen of this shell command line in an empty directory? touch .a .b .c ; echo .??* a. no output on screen b. .a .b .c c. .??* d. . .. .a .b .c e. an error message from echo saying .??* does not exist 52. If file foo contains ninety-nine lines, each of which is the two-digit line number of the line in the file (01 through 99), what is the output on your screen of this command: sort -r foo foo | tail -4 | head -1 a. 96 96 c. 98 e. 02 b. 04 04 d. 96 53. 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 c. :dp e. DDp b. ddp d. ddP 54. What is the output on your screen of this sequence of three shell commands: echo hi >wc ; ls wc >wc ; wc wc a. no output on screen d. 1 1 3 wc b. 0 0 0 wc e. 2 2 4 wc c. 1 1 2 wc 55. Which command sequence below outputs only lines 5-10 of the file named foo? a. head -10 foo | tail -6 d. head -15 foo | tail -5 b. tail -15 foo | head -5 e. head -5 foo | tail -10 c. tail -10 foo | head -6 56. If my current directory is /usr, which of these pathnames is equivalent to the pathname /usr/x/y/z? a. x/./y/z c. ../usr/y/z e. /x/y/z b. ./usr/x/y/z d. ../x/y/z 57. Which command line below does not show any lines from inside the file dog? a. sort -r dog c. ls dog e. head -3 dog b. tail -8 dog d. less dog 58. If my current directory is /home, which of these pathnames is equivalent to the pathname /home/a/b/c? a. ../home/b/c c. ../a/b/c e. /a/b/c b. ./a/b/c d. ./home/a/b/c 59. 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 nine nine | tail -4 | head -1 a. 6 6 c. 4 4 e. 6 b. 8 d. 1 1 60. Which command pipeline outputs the count of the number of userids containing the string allen that are currently logged in? a. who | wc allen | grep d. grep allen | wc | who b. who | grep allen | wc e. grep allen | who | wc c. who | grep | allen wc 61. Which command line takes the list of users currently logged in to the machine and displays just the one line containing the userid that sorts first in the alphabet? a. sort who | tail -1 d. head -1 who | sort b. sort | who | head -1 e. head -1 sort who c. who | sort -r | tail -1 62. 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 ALT key. b. Type [CONTROL]-[D] and the shell will present a menu of commands. c. Push key F1 and the system will present a menu of commands. d. You can type the first part of the command or file name and press the TAB key. e. Type [CONTROL]-[C] and the shell will present a menu of commands. 63. What is the output on your screen of this shell command line in an empty directory? echo ? a. . b. .. c. ? d. an error message from echo saying ? does not exist e. no output on screen 64. In an empty directory, what appears on your screen after this bash command line? touch a ; ls >wc -l a. 1 d. no output on screen b. 2 e. 0 c. 3 65. In an empty directory, how many words are in file cow after this bash shell command line? touch dog dog cat ; ls >cow a. 1 d. 3 b. 4 e. no output (empty file) c. 2 66. What appears on your screen after this bash shell command line? echo hi >a ; cat a | wc -c a. no output on screen d. 1 b. 4 e. 2 c. 3 67. If my current directory is /bin, which of these pathnames is equivalent to the file name /bin/ls? a. ls/. c. ../../bin/ls e. /root/bin/ls b. ./bin/ls d. ../bin/ls/. 68. 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. echo in1 in2 >out d. cp in1 in2 >out b. cp in1 >out in2 >out e. cat in1 in2 >out c. mv in1 in2 >out 69. What command shows all the lines in file foo that contain the string group? a. grep foo group d. grep group foo b. cat foo | wc group e. cat foo ; grep group c. grep group ; foo 70. 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 | sort | tail -4 | head -1 a. 6 d. 1 b. 8 e. 4 c. no output on screen 71. Which command shows the name of the current computer: a. hostname c. w e. ifconfig b. du d. who 72. Which of the following shell command lines displays only the names in the current directory that are exactly three alphabetic letters long? a. echo [a-zA-Z][a-zA-Z][a-zA-Z] d. echo [0-3][0-3][0-3] b. echo [?][?][?] e. echo ??? c. echo *** 73. If directory /dir contains 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/.123 /dir/.124 /dir/.??? b. echo: /dir/????: No such file or directory c. /dir/???? d. /dir/.123 /dir/.124 e. no output on screen 74. What would you see if you typed this command: cat /foo a. The contents of your directory named foo b. The contents of the file foo located in the root directory c. The contents of the file foo located in the parent directory d. The contents of your subdirectory named foo e. The contents of the file foo located in your home directory 75. What is true about this bash shell command line? date >ls ; ls -ls ls >wc a. The wc command counts the output of the ls command. b. The shell finds and executes three different commands. c. The file wc has one line in it. d. The ls command receives the output of date on standard input. e. The ls command is executed more than once. 76. If directory /a/b contains these four three-character file names: .aa, .ab, .a?, .a*, then what is the output on your screen of the following bash shell command line: echo /a/b/??? a. no output on screen b. /a/b/.aa /a/b/.ab c. /a/b/.a? d. /a/b/??? e. /a/b/.aa /a/b/.ab /a/b/.a? /a/b/.a* 77. 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. 4 c. 2 e. 3 b. none d. 1 78. How many lines are in the file out after this command sequence: echo hi >out ; echo ho >out ; cat out out >out a. 1 b. 6 c. nothing - empty file - no data d. 2 e. 3 79. Which command pipeline outputs the count of the number of pathnames that lie under the current directory and recursively under all its subdirectories? a. file . | wc c. find . | wc e. ls / | wc b. dir / | wc d. ls . | wc 80. What command shows all the lines in file foo that contain the string bar? a. grep bar >foo d. grep foo bar b. grep cat foo bar e. cat foo > grep bar c. grep bar foo 81. If you type the command echo 'missing quote which of the following key sequences will interrupt it and take you immediately back to the command prompt? a. [CTRL-R] c. [CTRL-C] e. [CTRL-D] b. [CTRL-U] d. [CTRL-L] 82. What appears on your screen after this command line? mkdir xx ; rmdir xx | wc -c a. 0 d. 3 b. 2 e. no output on screen c. 1 83. Given an existing file of yours named wc, what is the output on your screen of this sequence of three shell commands: echo hi >wc ; sort wc >wc ; cat wc a. no output on screen d. 2 2 4 wc b. 1 1 2 wc e. 1 1 3 wc c. 0 0 0 wc 84. How do I change "foo" to "bar" on lines 25 to 30 in the vim editor? a. :25,30s/foo/bar/ d. :25s/foo/bar/*5 b. :25,30 change "foo" "bar" e. :25c foo bar *5 c. :25-30 change "foo","bar" 85. 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. 4 c. 1 e. 2 b. 3 d. none 86. What is the output on your screen of this successful command line? cd /home/myhome ; mkdir foo ; mkdir bar ; pwd a. /home/myhome/foo/bar d. /home/myhome/bar b. /bar e. /home/myhome c. /home/myhome/foo 87. 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 | cat | tail -5 | head -1 a. 7 c. 5 e. 6 b. 8 d. 9 88. How many lines are in the file out after this command sequence: echo hi >x ; echo ho >>x ; cat x x x >out a. nothing - empty file - no data b. 6 c. 3 d. 2 e. 1 89. 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. echo a b >foo d. cp a b >foo b. mv a b >foo e. cat a >foo ; cat b >>foo c. cp a >foo ; cp b >>foo 90. What text is output by this bash shell command sequence: echo cow >foo ; echo dog | head -1 foo a. dog followed by cow d. foo b. cow e. dog c. cow followed by dog 91. What appears on your screen after this command line? echo hi >ls ; cat ls >wc a. no output on screen d. hi b. 1 1 3 e. ls c. 1 1 2 92. What is the output on your screen of this shell command line in an empty directory? cat * a. no output on screen b. an error message from cat saying * does not exist c. . d. . .. e. * 93. What is the output on your screen of this command sequence: echo bat >one ; echo sky | head -2 one a. sky followed by bat d. an error message b. sky e. bat c. bat followed by sky 94. Which command line finds all possible utilities available for compiling programs? a. man * | grep compile d. grep /etc/* compile b. apropos compile e. man compile c. grep compile /etc/* 95. If file twenty contains 20 lines, and file thirty contains 30 lines, then how many lines are output on your screen by this command: tail twenty | cat thirty a. 30 d. 20 b. 40 e. 50 c. no output on screen 96. Which of these statements is true? a. You can only login to Unix once per userid; you cannot be logged in to the same machine twice. b. Unix commands must be entered in lower-case letters. c. To indicate End-of-File (no more input), type [CONTROL]-[E]. d. Unix commands can be entered in upper-case or lower-case letters; they are equivalent. e. To erase an entire line of typing, type [CONTROL]-[E]. 97. What appears on your screen after this bash shell command line? echo hi >a ; echo a | wc -c a. 2 d. 1 b. no output on screen e. 3 c. 4 98. If you type the command grep pattern which of the following key sequences will send an EOF and take you immediately back to the command prompt? a. [CTRL-R] c. [CTRL-C] e. [CTRL-U] b. [CTRL-D] d. [CTRL-L] 99. What is the output on your screen of this shell command line in an empty directory? touch .1 .2 .3 4 5 6 ; echo .* a. an error message from echo saying .* does not exist b. .1 .2 .3 4 5 6 c. 4 5 6 d. .* e. . .. .1 .2 .3 100. What appears on your screen after this bash shell command line? echo hi >a ; cp a b | wc -c a. 0 d. 1 b. 3 e. 2 c. no output on screen 101. Which of these commands always returns you to your account home directory? a. cd c. cd /home/.. e. cd /home b. cd .. d. cd home 102. What would you see if you typed this command: cat /users a. The contents of your directory named users b. The contents of your subdirectory named users c. The contents of the file users located in the parent directory d. The contents of the file users located in your home directory e. The contents of the file users located in the root directory 103. In an empty directory, how many arguments are passed to the wc command in this command line? date >o1 ; touch a1 b2 out >o1 ; wc o* a. 5 c. 3 e. 1 b. 4 d. 2 104. What appears on your screen after this bash shell command line? echo hi >a ; ls a | wc -c a. 3 d. no output on screen b. 2 e. 4 c. 1 105. If my current directory is /home, which of these pathnames is equivalent to the pathname /home/a/b/c? a. ../home/b/c c. ../a/b/c e. ../home/a/b/c b. ./home/a/b/c d. /a/b/c 106. If you type the command sort verybigfile >out which of the following key sequences will interrupt it and take you immediately back to the command prompt? a. [CTRL-U] c. [CTRL-C] e. [CTRL-L] b. [CTRL-R] d. [CTRL-D] 107. What is in file two after running this command line? echo one >two three four a. three four d. echo one b. one three four e. empty file (no data) c. one 108. If /bin/bash is a file name, which pathname always leads to the same file? a. /../../bin/bash c. /bin/../bash e. /bin/bash/.. b. ./bin/bash d. /bin/bash/. 109. Which of the command lines below can generate a non-empty file? a. head -1 file >file d. cat file >file b. ls -l file >file e. grep pattern file >file c. sort -r file >file 110. What command shows all the lines in file /etc/group that contain the string idallen? a. grep /etc/group idallen d. grep idallen /etc/group b. cat /etc/group > grep idallen e. cat /etc/group | wc idallen c. grep idallen >/etc/group 111. 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. 120 d. 70 b. 80 e. 50 c. no lines (empty file) 112. If my current directory is /etc, which of these pathnames is equivalent to the file name /etc/passwd? a. /passwd c. ../passwd e. ./etc/passwd b. ./passwd d. ../etc/passwd/. 113. If file x contains 10 lines, and file y contains 20 lines, then how many lines are in file cat after this command line: sort x y >z ; tail -5 x >x ; sort x y z >cat a. no lines (empty file) d. 60 b. 40 e. 55 c. 50 114. If file a contains 20 lines, and file b contains 30 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. no lines (empty file) d. 30 b. 100 e. 60 c. 50 115. 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 | sort -r | head -5 | tail -1 a. 7 c. 8 e. 6 b. 5 d. 9 116. What is the output on your screen of this sequence of three shell commands: echo x >abc ; ls >abc abc ; wc abc a. 1 1 2 abc d. no output on screen b. 0 0 0 abc e. 1 1 4 abc c. 1 1 3 abc 117. What appears on your screen after this bash shell command line? echo cow | wc a. no output on screen d. 1 1 3 b. 1 1 4 e. 1 3 1 c. 3 1 1 118. What is in file out after running this bash shell command line? echo 2 3 >out 3 0 a. 2 3 3 0 d. 2 3 0 b. 2 3 >out 3 0 e. 2 3 c. no output (empty file) 119. If you type the command sleep 60 which of the following key sequences will interrupt it and take you immediately back to the command prompt? a. [CTRL-R] c. [CTRL-C] e. [CTRL-U] b. [CTRL-D] d. [CTRL-L] 120. If foo is a sub-directory that contains only the file single, what happens after this command: mv ./foo/single foo/../double a. there is a second copy of the file single in the file named double b. the directory foo now contains only a file named double c. the command fails because the name foo/../double does not exist d. the command fails because the name double does not exist e. the directory foo is now empty 121. What is the output on your screen of this shell command line in an empty directory? touch .12 .345 .6789 ; echo .??* a. .12 .345 .6789 b. an error message from echo saying .??* does not exist c. no output on screen d. .??* e. . .. .12 .345 .6789 122. What appears on your screen after this bash shell command line? echo hi | wc -c a. 3 d. 2 b. no output on screen e. 1 c. 0 123. If you type the command head which of the following key sequences will send an EOF and take you immediately back to the command prompt? a. [CTRL-L] c. [CTRL-R] e. [CTRL-U] b. [CTRL-D] d. [CTRL-C] 124. Which of these command lines will make file cow contain all of the content of file one followed by all of the content of file two? a. cat one two >cow d. echo one two >cow b. cp one >cow two >cow e. cp one two >cow c. mv one two >cow 125. Given an existing file of yours named /a/x, what is the output on your screen of this sequence of three shell commands: echo hi >/a/x ; sort /a/x >/a/x ; wc /a/x a. 1 1 3 /a/x d. 1 1 2 /a/x b. 0 0 0 /a/x e. no output on screen c. 2 2 4 /a/x 126. What is in file cow after running this bash shell command line? echo one two >cow three a. no output (empty file) d. echo one two b. one two three e. one two c. one two cow three 127. 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. 1 c. 6 d. 2 e. nothing - empty file - no data 128. Which command line displays the contents of the Unix passwd file one page at a time? a. /etc/passwd | less d. /etc/passwd cat less b. cat less | /etc/passwd e. less /etc/passwd c. cat /etc/passwd less 129. Which of the following statements is true about this shell command line: >bar zoom bar haven a. The command bar sees only two arguments b. The command zoom sees three arguments. c. The command zoom sees two arguments. d. The command bar sees three arguments. e. Error: The command name is missing from the command line. 130. 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: cat nine nine | sort -r | head -4 | tail -1 a. 9 c. 7 e. 5 b. 6 d. 8 131. What is the output on your screen of this successful command sequence? cd /home/foo ; touch dir ; mkdir bar ; pwd a. /home/foo d. /home/foo/dir/bar b. /home/foo/dir e. /bar c. /home/foo/bar 132. In an empty directory, how many arguments are passed to the cat command in this bash command line? touch a1 a2 ac ba .a ; cat a* a. 1 c. 3 e. none b. 2 d. 4 133. How many command arguments does the shell pass to this echo command: echo one two three >four five a. Six arguments. c. Three arguments. e. Five arguments. b. Four arguments. d. Two arguments. 134. If my current working directory is /home, and my home directory is /home/xx, which of the of the following commands copies the Unix password file into my home directory under the name foo? a. cp xx/../../etc/passwd xx/foo b. cp xx/../etc/passwd ../home/xx/foo c. cp ../../etc/passwd /xx/foo d. cp ../home/xx/../etc/passwd ./xx/./foo e. cp ../etc/passwd ../xx/foo 135. What is the output on your screen of this successful command sequence? cd /home/dir ; mkdir one ; mkdir two ; pwd a. /home/dir d. /home/dir/one/two b. /home/dir/one e. /home/dir/two c. /two 136. In an empty directory, what appears on your screen after this bash command line? touch a ; ls | wc -l a. 0 d. 3 b. 2 e. no output on screen c. 1 137. In an empty directory, how many words are in file out after this bash shell command line? touch a ; ls >out a. 1 d. no output (empty file) b. 2 e. 3 c. 4 138. If file x contains 10 lines, and file y contains 20 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. 40 d. no lines (empty file) b. 60 e. 50 c. 45 139. What is the output on your screen of this shell command line in an empty directory? touch a .a bc .bc def ; echo [ab]* a. an error message from echo saying [ab]* does not exist b. [ab]* c. a bc d. no output on screen e. a .a bc .bc 140. What is the output on your screen of this shell command line in an empty directory? touch 1 2 3 .a .b .c ; echo .??* a. . .. .a .b .c b. .??* c. an error message from echo saying .??* does not exist d. . .. 1 2 3 .a .b .c e. .a .b .c 141. Which command sequence below outputs only lines 10-15 of the Unix password file? a. tail -15 /etc/passwd | head -10 b. head -15 /etc/passwd | tail -5 /etc/passwd c. tail -10 /etc/passwd | head -15 /etc/passwd d. head -10 /etc/passwd | tail -15 /etc/passwd e. head -15 /etc/passwd | tail -6 142. 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. two followed by one c. one followed by two d. empty file - no output on the screen e. two 143. What appears on your screen after this bash shell command line? echo hi >a ; ls a > wc a. 1 1 3 d. 1 1 2 b. no output on screen e. 2 c. 3 144. 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 nine nine nine | tail -3 | head -1 a. 8 c. 7 e. 9 b. 1 1 1 d. 7 7 7 145. What is the output on your screen of this sequence of this command sequence: echo hi >hi ; head hi >hi ; wc hi a. 1 1 2 hi d. no output on screen b. 2 2 4 hi e. 1 1 3 hi c. 0 0 0 hi 146. What is the output on your screen of this shell command line in an empty directory? touch .a .b .c ; echo [.]* a. no output on screen b. an error message from echo saying [.]* does not exist c. . .. .a .b .c d. [.]* e. .a .b .c 147. How many lines are in the file bar after this command line: echo hi >x ; echo ho >>x ; cat x >bar a. 1 b. nothing - empty file - no data c. 2 d. 4 e. 6 148. Which of the command lines below can generate a non-empty file? a. tail /a/b >/a/b d. head -5 /a/b >/a/b b. sort /a/b >/a/b e. cat /a/b /a/b /a/b >/a/b c. wc -l /a/b >/a/b 149. Which command pipeline outputs the count of the number of manual page titles that contain the keyword "sort"? a. man -k sort | wc c. wc -k sort e. man sort | wc b. man sort ; wc d. wc man sort 150. If I am in my home directory named /home/ian and mt is an empty sub- directory, what is true after this command line: touch ../ian/cat ; cp ./mt/../cat ./mt/../dog a. the directory mt now contains two files b. the file named cat is now renamed to be dog c. the command fails because the path ./mt/../cat does not exist d. the directory mt is still empty e. the directory mt now has a file named dog in it 151. If /etc/passwd is a file name, which pathname always leads to the same file? a. /etc/passwd/./. d. /etc/../../passwd b. /etc/passwd/../.. e. ././etc/passwd c. /./../etc/./passwd 152. 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 | cat | tail -4 | head -1 a. 7 c. 9 e. 6 b. 8 d. 5 153. Which command line below never shows any lines from inside the file cow? a. wc -l cow c. head -1 cow e. grep pattern cow b. sort -r cow d. tail -8 cow 154. What is the output on your screen of this shell command line in an empty directory? touch 1 .1 23 .23 456 ; echo [12]* a. 1 23 b. [12]* c. 1 .1 23 .23 456 d. 1 .1 23 .23 e. an error message from echo saying [12]* does not exist 155. What can you do to get back (redo) the last command you typed to the bash shell? a. Use the "UpArrow" key. d. Type the k key. b. Type [CONTROL]-[ALT]-[UP] e. Use the "PageUp" key. c. Type [ALT]-[F2] 156. How many lines are in file out after this bash shell command line? echo hi >dog >cat >out a. 1 b. 3 c. nothing - empty file - no data d. 2 e. no such file (file does not exist) 157. If you type the command cat which of the following key sequences will send an EOF and take you immediately back to the command prompt? a. [CTRL-C] c. [CTRL-D] e. [CTRL-L] b. [CTRL-R] d. [CTRL-U] 158. What is the possible output on your screen of this command line: echo wc >date ; sort date >date ; cat date a. 1 6 29 date d. no output on screen b. wc e. 1 6 28 date c. Tue Feb 5 10:01:35 EST 2008 159. If I am in my home directory named /home/idallen and empty is an empty sub- directory, what is true after this command line: touch ./pig ; mv ./empty/../pig ../idallen/cow a. the directory empty now contains only a file named cow b. the command fails because path ./empty/../pig does not exist c. there is a second copy of the file pig in the file named cow d. the directory empty/.. now has a file named cow in it e. the command fails because path ../idallen/cow does not exist 160. In an empty directory, how many arguments are passed to the rm command in this bash command line? touch 2a a a1 ba ca .a ; rm a* a. 4 c. 3 e. none b. 1 d. 2 161. What appears on your screen after this bash shell command line? echo xx >z ; ls z > wc a. no output on screen d. 2 b. 1 1 3 e. 1 1 2 c. 3 162. What appears on your screen after this bash shell command line? echo hi >ls ; cat ls > wc a. 1 1 2 d. ls b. 1 1 3 e. hi c. no output on screen 163. What command can you use to remove a directory that isn't empty? a. rmdir -r dir c. rm -r dir e. deldir -r dir b. del -r dir d. mv -r dir 164. What is the output on your screen of this shell command line in an empty directory? echo * a. . b. no output on screen c. an error message from echo saying * does not exist d. . .. e. * 165. If file twenty contains 20 lines, and file thirty contains 30 lines, then how many lines are output on your screen by this command: tail thirty | cat twenty a. 20 d. 50 b. 30 e. 21 c. no lines (no output) 166. What is the output on your screen of the following sequence of commands: echo wc >wc ; wc wc >wc ; cat wc a. 1 1 3 wc d. wc b. 0 0 0 wc e. 1 1 2 wc c. no output on screen 167. What text is output by this bash shell command sequence: echo dog >out ; echo cat | sort out a. cat d. dog followed by cat b. cat followed by dog e. out c. dog 168. In an empty directory, how many arguments are passed to the rm command in this bash command line? touch a a1 a2 ba ca ; rm a* a. 1 c. 2 e. none b. 4 d. 3 169. What is the output on your screen of this command sequence: echo foo >file ; echo bar | sort file a. foo followed by bar d. foo b. bar followed by foo e. an error message c. bar 170. 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: cat nine nine | tail -5 | head -1 a. 7 c. 5 e. 8 b. 6 d. 9 171. In an empty directory, how many arguments are passed to the cat command in this bash command line? touch a1 a2 ba ca ; cat a* a. 3 c. 2 e. 4 b. none d. 1 172. If /etc/passwd is a file name, which pathname always leads to the same file? a. ./etc/passwd d. /etc/passwd/. b. /etc/./etc/../passwd e. ../etc/passwd c. /etc/../etc/passwd 173. When doing an ls -a, the output pathname that is a double dot (..) signifies what? a. A hidden text file. b. The parent directory. c. The root directory. d. A file or directory with double links. e. The current directory. 174. What is the output on your screen of this shell command line in an empty directory? touch x .a .ab .cde .fghi ; echo .??* a. .ab .cde .fghi b. .??* c. . .. .a .ab .cde .fghi d. .cde .fghi e. an error message from echo saying .??* does not exist 175. What appears on your screen after this bash shell command line? echo hi >out ; wc -c out a. 5 out d. 3 out b. 4 out e. 2 out c. no output on screen 176. Which Unix command sequence deletes a directory and everything inside it? a. rm -all dir c. rmdir -r dir e. rm -r dir b. deltree -all dir d. rmdir -all dir This page intentionally left blank. Answer Key - NET2003 - Ian Allen - Winter 2008 - NET2003 Practice Test 1. a 57. c 2. c 58. b 3. e 59. b 4. a 60. b 5. a 61. c 6. c 62. d 7. e 63. c 8. d 64. d 9. a 65. d 10. a 66. c 11. a 67. c 12. b 68. e 13. e 69. d 14. c 70. b 15. a 71. a 16. d 72. a 17. d 73. c 18. e 74. b 19. e 75. c 20. b 76. d 21. e 77. c 22. d 78. c 23. c 79. c 24. e 80. c 25. b 81. c 26. c 82. a 27. c 83. a 28. b 84. a 29. a 85. b 30. e 86. e 31. b 87. c 32. e 88. b 33. d 89. e 34. b 90. b 35. e 91. a 36. d 92. b 37. c 93. e 38. a 94. b 39. b 95. a 40. e 96. b 41. d 97. a 42. e 98. b 43. e 99. e 44. a 100. a 45. c 101. a 46. d 102. e 47. d 103. d 48. b 104. b 49. b 105. e 50. c 106. c 51. c 107. b 52. e 108. a 53. b 109. b 54. d 110. d 55. a 111. d 56. a 112. b 113. c 173. b 114. c 174. a 115. a 175. d 116. e 176. e 117. b 118. a Count of a: 42 24% 119. c Count of b: 36 20% 120. e Count of c: 42 24% 121. a Count of d: 27 15% 122. a Count of e: 29 16% 123. b 124. a With 5 choices: 176 125. b 126. b Macro .cmd split with good indent: 68 127. a 128. e 129. c 130. d 131. a 132. c 133. b 134. a 135. a 136. c 137. b 138. a 139. c 140. b 141. e 142. a 143. b 144. e 145. c 146. d 147. c 148. c 149. a 150. d 151. c 152. e 153. a 154. a 155. a 156. a 157. c 158. d 159. d 160. d 161. a 162. c 163. c 164. e 165. a 166. b 167. c 168. d 169. d 170. c 171. c 172. c