Practice Test DAT2330 - Ian Allen - Fall 2003-1- PRACTICE Evaluation: 85 Questions Name: _________________________ 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 - 85 Questions This is a practice test containing practice questions. The real test will contain many questions similar to these. Knowing the concepts behind the questions is necessary; memorizing these answers won't help. The real test may or may not have the same number of questions. The real test may have some questions unlike anything given here. (Office use only: 40 62 70 45 21 79 56 43 17 1 18 15 60 7 54 61 72 35 41 42 75 67 10 58 48 5 23 74 80 11 49 4 37 66 57 76 12 55 36 81 65 14 53 59 28 63 47 77 16 68 39 6 44 8 34 38 13 78 71 25 26 20 73 52 85 64 32 51 33 30 27 50 83 46 31 84 9 3 2 82 29 22 69 19 24) 1. If file foo contains nine lines, each of which is the number of the line in the file, what is the output of this command: cat foo foo | sort | tail -4 | head -1 a. 4 b. 6 c. no output d. 8 e. 1 2. If directory /a/b contains these four three-character file names: .aa, .ab, .a?, .a*, then what is the output of the following bash shell command line: echo /a/b/??? a. /a/b/.a? b. /a/b/??? c. no output d. /a/b/.aa /a/b/.ab e. /a/b/.aa /a/b/.ab /a/b/.a? /a/b/.a* 3. What appears on your screen after this bash shell command line? echo hi >a ; cp a b | wc -c a. 0 b. 1 c. 3 d. 2 e. no output 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-2- PRACTICE 4. How many arguments and options are there to the command: ls -li foobar 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. Two arguments, no options. d. One argument, no options. e. Two options, no arguments. 5. How many arguments does the shell pass to this echo command: echo ' one two ' three ' four ' 5'6' a. Four arguments. b. Six arguments. c. One argument. d. Five arguments. e. Nine arguments. 6. In an empty directory, what appears on your screen after this bash command line? ls nosuchfile 2>out a. nosuchfile not found b. 2 not found c. nosuchfile 2 not found d. nosuchfile e. no output 7. 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 is always invalid. d. The command cat sees two arguments. e. The command cat sees only one argument. 8. 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 can be entered in upper-case or lower-case letters; they are equivalent. c. To erase an entire line of typing, type [CONTROL]-[E]. d. Unix commands must be entered in lower-case letters. e. To indicate End-of-File (no more input), type [CONTROL]-[E]. 9. Which command below removes only this four-character file name containing a special character (and no others): cat? a. rm cat/? b. rm \cat? c. rm ''cat?'' d. rm "cat?" e. rm ""cat?"" 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-3- PRACTICE 10. 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-D] b. [CTRL-I] c. [CTRL-C] d. [CTRL-U] e. [CTRL-R] 11. 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. Three arguments. e. Two arguments. 12. 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-D] b. [CTRL-I] c. [CTRL-R] d. [CTRL-U] e. [CTRL-C] 13. Which of the following shell command lines displays only the names in the current directory that are exactly three alphabetic letters long? a. echo ??? b. echo [?][?][?] c. echo [a-zA-Z][a-zA-Z][a-zA-Z] d. echo *** e. echo [0-3][0-3][0-3] 14. 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] b. [CTRL-R] c. [CTRL-U] d. [CTRL-D] e. [CTRL-I] 15. If file /a/b 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 of this command: sort /a/b /a/b | tail -4 | head -1 a. 01 01 b. 04 04 c. 96 d. 96 96 e. 98 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-4- PRACTICE 16. If directory /a contains these seven two-character file names: aa, ab, ac, ad, a?, a*, a., then which shell command below will remove only the single name a? from the directory? a. rm /a? b. rm /a/a? c. rm /a/a\? d. rm /a/a[*] e. rm /a/a* 17. What appears on your screen after this bash shell command line? echo hi >a ; cat a | wc -c a. 1 b. 2 c. 3 d. no output e. 4 18. If /bin/bash is a file name, which of the following pathnames always leads to the same file? a. ./bin/bash b. /bin/bash/. c. /bin/../bash d. /../../bin/bash e. /bin/bash/.. 19. What is the output of this command sequence: echo foo >file ; echo bar | sort file a. foo followed by bar b. an error message c. bar followed by foo d. bar e. foo 20. What can you do to get back (redo) the last command you typed to the bash (Linux) shell? a. Type [CONTROL]-[ALT]-[DEL] b. Use the "UpArrow" key. c. Use the "PageUp" key. d. Type [ALT]-[F2] e. Type [CONTROL]-[BACKSPACE] 21. In an empty directory, what appears on your screen after this bash command line? touch a ; ls >wc -l a. 0 b. no output c. 3 d. 2 e. 1 22. What appears on your screen after this bash shell command line? echo hi | wc -c a. no output b. 1 c. 3 d. 0 e. 2 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-5- PRACTICE 23. If cow is a sub-directory that contains only the file dog, what happens after this command: mv cow/dog cow/././cat a. there is a second copy of the file dog in the file named cat b. the command fails because the name cat does not exist c. the directory cow is now empty d. the command fails because the name cow/././cat does not exist e. the directory cow now contains only a file named cat 24. 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. 80 c. 160 d. 50 e. no lines (empty file) 25. Which command line below does not show any lines from inside the file dog? a. more dog b. tail dog c. ls dog d. head dog e. less dog 26. 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. no output b. 1 1 2 /a/x c. 1 1 3 /a/x d. 0 0 0 /a/x e. 2 2 4 /a/x 27. If I am in my home directory named /home/myhome and sub is an empty sub-directory, what is true after this command line: touch ./fil ; mv sub/../fil ../myhome/cat a. the directory sub now contains only a file named cat b. the command fails because the path ../myhome/cat does not exist c. the command fails because the path sub/../fil does not exist d. there is a second copy of the file fil in the file named cat e. the directory sub/.. now has a file named cat in it 28. What appears on your screen after this bash shell command line? echo hi >a ; ls a > wc a. 1 1 2 b. 3 c. 2 d. no output e. 1 1 3 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-6- PRACTICE 29. In an empty directory, how many lines are in file out after this bash shell command line? ls . .. nosuchfile 2>out a. 2 b. 1 c. 4 d. no output (empty file) e. 3 30. 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. no output b. 2 2 4 wc c. 0 0 0 wc d. 1 1 2 wc e. 1 1 3 wc 31. Which command line displays the contents of the Unix passwd file one page at a time? a. /etc/passwd >more b. more | /etc/passwd c. cat /etc/passwd >more d. /etc/passwd | more e. more /etc/passwd 32. If foo is a sub-directory that contains only the file single, what happens after this command: mv ./foo/single foo/../double a. the directory foo now contains only a file named double b. the command fails because the name foo/../double does not exist c. there is a second copy of the file single in the file named double d. the directory foo is now empty e. the command fails because the name double does not exist 33. Which command sequence outputs inode/filename pairs for names in the working directory, sorted by inode number? a. ls | sort -i b. ls -node | sort -n c. echo -i * > sort d. echo * | sort -n e. ls -ia | sort -n 34. What appears on your screen after this bash shell command line? mkdir foo ; rmdir foo | wc -c a. no output b. 3 c. 4 d. 1 e. 0 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-7- PRACTICE 35. Which of the command lines below can generate a non-empty file? a. cat /a/b >/a/b b. grep /a/b /a/b >/a/b c. tail -5 /a/b >/a/b d. ls -i /a/b >/a/b e. sort -r /a/b >/a/b 36. In an empty directory, what appears on your screen after this bash command line? touch a ; ls | wc -l a. 1 b. 3 c. 0 d. no output e. 2 37. In the output of the command ls -a, a dot that begins a name signifies what? a. The parent directory. b. A name that is hidden. c. The current directory. d. A current file. e. A name with an unprintable character. 38. 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. no output b. 1 1 2 /a/b/x c. 1 1 1 /a/b/x d. 0 0 0 /a/b/x e. 1 1 3 /a/b/x 39. Which Unix command sequence deletes a directory and everything inside it? a. deltree -all dir b. rm -r dir c. rmdir -r dir d. rm -all dir e. rmdir -all dir 40. In an empty directory, how many lines are in file out after this bash shell command line? touch a ; ls >out a. 2 b. 3 c. no output (empty file) d. 4 e. 1 41. What is the output of this bash shell command line in an empty directory? echo '$SHELL' a. /bin/bash b. '/bin/bash' c. no output d. '$SHELL' e. $SHELL 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-8- PRACTICE 42. 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-D] b. [CTRL-C] c. [CTRL-U] d. [CTRL-I] e. [CTRL-R] 43. What command can you use to remove a directory that isn't empty? a. del -r dir b. mv -r dir c. rm -r dir d. rmdir -r dir e. deldir -r dir 44. 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. 30 b. 50 c. 20 d. no lines (empty file) e. 80 45. Which of the following will not cause file1 to become an empty file? a. head file1 > file1 b. tail file1 > file1 c. wc file1 > file1 d. sort file1 > file1 e. cat file1 > file1 46. Which of the command lines below can generate a non-empty file? a. sort /a/b >/a/b b. head -5 /a/b >/a/b c. wc -l /a/b >/a/b d. cat /a/b /a/b /a/b >/a/b e. tail /a/b >/a/b 47. How can you ask the bash (Linux) shell to complete commands or file names for you? a. Type [CONTROL]-[D] 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 [ALT]-[F2] the shell will present a menu of commands. d. Type [CONTROL]-[ALT]-[DEL] and 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. 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-9- PRACTICE 48. What is the correct syntax to redirect both standard output and standard error into the same output file? a. command 2>1 >out b. command 2>&1 >out c. command >out 2>1 d. command >out 2>&1 e. command 2>out >out 49. Which command below removes only this four-character file name containing a special character (and no others): *dog a. rm ./\*dog b. rm .\/*dog c. rm ?dog d. rm /*dog e. rm \\*dog 50. What appears on your screen after this bash shell command line? echo hi >out ; wc -c out a. 3 out b. 5 out c. 2 out d. 4 out e. no output 51. What command shows all the lines in file /etc/group that contain the string idallen? a. grep /etc/group idallen b. cat /etc/group > grep idallen c. grep idallen /etc/group d. grep idallen >/etc/group e. cat /etc/group | wc idallen 52. If directory /a contains these seven two-character file names: aa, ab, ac, ad, a?, a*, a., then which shell command below will remove only the single name a* from the directory (and no others)? a. rm /a/a\* b. rm /a/a* c. rm /a* d. rm /a/* e. rm /a/a? 53. Which of these statements is true? a. The file command creates a new, empty file in the current directory b. To erase an entire line of typing, type [ALT]-[DELETE]. c. To indicate End-of-File (no more input) to a program, type [CONTROL]-[D]. d. To telnet to ACADAIX from outside the College, use the name acadaix.algonquin. e. To interrupt a Unix process from the keyboard, type [CONTROL]-[D]. 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-10- PRACTICE 54. Which command below removes only this five-character file name containing a special character (and no others): date? a. rm date\* b. rm ./date\? c. rm date\\? d. rm date/? e. rm ./date? 55. If my current directory is /home, which of these pathnames is equivalent to the pathname /home/a/b/c? a. ./a/b/c b. ../home/b/c c. ./home/a/b/c d. /a/b/c e. ../a/b/c 56. Which command sequence below outputs only lines 10-15 of the Unix password file? a. head -15 /etc/passwd | tail -6 b. tail -10 /etc/passwd | head -15 /etc/passwd c. head -15 /etc/passwd | tail -5 /etc/passwd d. tail -15 /etc/passwd | head -10 e. head -10 /etc/passwd | tail -15 /etc/passwd 57. In the output of the command ls -ai, the one-character name . signifies what? a. The current directory. b. A current file. c. A name with an unprintable character. d. The parent directory. e. A name that is hidden. 58. In an empty directory, what is in file out after this bash command line? ls nosuchfile | wc -l >out a. no output (empty file) b. 1 c. 11 d. 0 e. 10 59. What appears on your screen after this bash shell command line? echo hi >a ; echo a | wc -c a. 1 b. no output c. 3 d. 2 e. 4 60. 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 512 is the size of this directory. b. The number 256 is the inode number of this directory. c. The number 256 is the size of this directory. d. The number 512 is the count of links (names) this directory has. e. The number 256 is the octal permissions of this directory. 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-11- PRACTICE 61. What is the output of this sequence of three shell commands: echo hi >hi ; head hi >hi ; wc hi a. 0 0 0 hi b. 2 2 4 hi c. 1 1 2 hi d. no output e. 1 1 3 hi 62. How many arguments does the shell pass to this echo command: echo 'And it's not hard, it's just logical.' a. Three arguments. b. Four arguments. c. Six arguments. d. Five arguments. e. Seven arguments. 63. What appears on your screen after this bash shell command line? echo hi >a ; ls a | wc -c a. no output b. 2 c. 1 d. 3 e. 4 64. What would you see if you typed this command: cat /users a. The contents of your directory named users b. The contents of the file users located in your home directory c. The contents of your subdirectory named users d. The contents of the file users located in the parent directory e. The contents of the file users located in the root directory 65. 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 ls command receives the output of date on standard input. c. The shell finds and executes three different commands. d. The ls command is executed more than once. e. The file wc has one line in it. 66. What is the output of this shell command line in an empty directory? echo * a. * b. . .. c. no output d. . e. .. 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-12- PRACTICE 67. 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. no such file (nonexistent) c. nothing - empty file - no data d. bar e. foo 68. When doing an ls -a, the output pathname that is a double dot (..) signifies what? a. The root directory. b. The current directory. c. A hidden file. d. The parent directory. e. A file or directory with double links. 69. What is the output of this successful command sequence? cd /home/foo ; touch dir ; mkdir bar ; pwd a. /home/foo/dir/bar b. /home/foo c. /home/foo/dir d. /home/foo/bar e. /bar 70. Which command stops people from using write to put lines of text on your screen? a. mesg n b. talk n c. write n d. chmod n e. stop n 71. What is the output of this sequence of three shell commands: echo hi >wc ; ls wc >wc ; wc wc a. 1 1 3 wc b. 0 0 0 wc c. 1 1 2 wc d. no output e. 2 2 4 wc 72. Which command below is the best way to find a line containing a question mark (?) in the file /etc/passwd? a. grep '?' /etc/passwd b. grep ? >/etc/passwd c. grep ? /etc/passwd d. grep ./? /etc/passwd e. grep /etc/passwd ./? 73. How many lines are in file out after this bash shell command line? echo hi >dog >out >cat a. no such file (file does not exist) b. 1 c. no output (empty file) d. 2 e. 3 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-13- PRACTICE 74. How many arguments and options are there to the command: ls -al /etc a. A three-letter file name and an /etc switch option. b. Two command line arguments, one of which contains two bundled options. c. Two options, no arguments. d. Two arguments, one of which is a single option and the other is a pathname. e. Two arguments, no options. 75. Which command line lists all possible utilities available for editing files? a. man edit b. whereis edit c. finger edit d. which edit e. man -k edit 76. What is in file out after running this bash shell command line? echo a >out b c a. b c b. no output c. a d. a b c e. echo a 77. Which command below removes only this five-character file name containing a special character (and no others): *test a. rm ./*test b. rm ''*test'' c. rm ./\\*test d. rm \\*test e. rm "*test" 78. Which command below removes only this four-character file name containing a special character (and no others): *xyz a. rm '*xyz' b. rm ''*xyz c. rm ''*xyz'' d. rm *'xyz' e. rm *xyz 79. Which command below removes only this four-character file name containing a special character (and no others): abc* a. rm abc\\* b. rm abc/* c. rm abc\* d. rm abc* e. rm abc//* 80. How many lines are in file out after this bash shell command line? echo hi >dog >cat >out a. 2 b. no such file (file does not exist) c. no output (empty file) d. 3 e. 1 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-14- PRACTICE 81. Which of these command sequences will make file3 contain all of the content of file1 followed by all of the content of file2? a. cat file1 file2 >file3 b. cp file1 >file3 file2 >file3 c. mv file1 file2 >file3 d. echo file1 file2 >file3 e. cp file1 file2 >file3 82. 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. the command fails because the path x/./fil does not exist c. there is a second copy of the file fil in the file named y d. the directory x is still empty e. the command fails because the path x/../../me does not exist 83. What appears on your screen after this bash shell command line? echo hi >out | wc -c a. no output b. 3 c. 1 d. 0 e. 2 84. How many arguments does the shell pass to this echo command: echo "cow "y " bat 'man x' " pig'a "hop' a b a. Six arguments. b. Seven arguments. c. Five arguments. d. Four arguments. e. Eleven arguments. 85. Which of the following is true, given this long directory listing from ls: drwxr-x--x 512 ian user 712 May 30 12:35 dir a. The number 512 is the size of this directory. b. The number 512 is the inode number of this directory. c. The number 712 is the inode number of this directory. d. The number 512 is the count of links (names) this directory has. e. The number 712 is the count of links (names) this directory has. 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-15- PRACTICE Answer Key - DAT2330 - Ian Allen - Fall 2003 - DAT2330 Practice Test - 0% Office use only: 40 62 70 45 21 79 56 43 17 1 18 15 60 7 54 61 72 35 41 42 75 67 10 58 48 5 23 74 80 11 49 4 37 66 57 76 12 55 36 81 65 14 53 59 28 63 47 77 16 68 39 6 44 8 34 38 13 78 71 25 26 20 73 52 85 64 32 51 33 30 27 50 83 46 31 84 9 3 2 82 29 22 69 19 24 1. d 49. a 2. b 50. a 3. a 51. c 4. a 52. a 5. a 53. c 6. e 54. b 7. e 55. a 8. d 56. a 9. d 57. a 10. c 58. d 11. d 59. d 12. a 60. a 13. c 61. a 14. d 62. b 15. e 63. b 16. c 64. e 17. c 65. e 18. d 66. a 19. e 67. c 20. b 68. d 21. b 69. b 22. c 70. a 23. e 71. a 24. b 72. a 25. c 73. c 26. d 74. b 27. e 75. e 28. d 76. d 29. b 77. e 30. a 78. a 31. e 79. c 32. d 80. e 33. e 81. a 34. e 82. d 35. d 83. d 36. a 84. c 37. b 85. d 38. d 39. b Count of a: 21 25% 40. a Count of b: 15 18% 41. e Count of c: 15 18% 42. b Count of d: 19 22% 43. c Count of e: 15 18% 44. b 45. c With 5 choices: 85 46. c 1 2 3 4 5 6 7 8 9 10 11 12 13 47. b 14 15 16 17 18 19 20 21 22 23 48. d 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 85 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-16- PRACTICE 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 Macro .cmd splits: 24 Macro .ans splits: 0 85 Questions DAT2330 Practice Test - 0% PRACTICE