Practice Test DAT2330 - Ian Allen - Fall 2003-1- PRACTICE Evaluation: 110 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 - 110 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: 35 39 71 36 30 44 66 63 72 86 8 106 27 51 4 105 87 88 9 55 97 101 85 21 65 23 109 13 108 60 61 16 24 14 46 69 32 5 80 3 41 18 89 28 77 48 7 34 62 91 49 57 83 103 58 56 40 50 84 102 15 75 12 64 67 99 45 26 73 78 76 33 95 37 54 98 90 6 22 53 81 19 17 92 104 110 47 52 43 20 42 96 2 94 79 59 82 70 25 38 93 29 10 31 1 74 68 11 100 107) 1. In an empty directory, what is the length of the longest file name created by the following bash shell two-command sequence: ok='1 12 123 1234' ; touch '$ok' a. 2 characters b. 4 characters c. 1 character d. 3 characters e. 13 characters 2. Which bash command sequence correctly searches for the chars and then prints OK if it is found inside the password file? a. if [ test chars /etc/passwd ] ; then echo OK ; fi b. if [ grep chars /etc/passwd ] ; then echo OK ; fi c. if test chars /etc/passwd ; then echo OK ; fi d. if grep chars /etc/passwd ; then echo OK ; fi e. if test chars = /etc/passwd ; then echo OK ; fi 3. Given my directory dir and my file dir/foo owned by me, which permissions allow me to change or create new content (data) in the file dir/foo but not delete the file? a. Permissions 400 on directory dir and 400 on file dir/foo. b. Permissions 200 on directory dir and 200 on file dir/foo. c. Permissions 600 on directory dir and 700 on file dir/foo. d. Permissions 500 on directory dir and 600 on file dir/foo. e. Permissions 100 on directory dir and 100 on file dir/foo. 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-2- PRACTICE 4. A shell script named foo is executed as follows: ./foo 1 "2 3 4" 5 Inside the script is the line: echo "$2" What is the output from this line? a. $2 b. 2 3 4 c. "2 d. 2 e. "2 3 4" 5. What is the output of the following sequence of bash commands: x=1 ; y=2 ; test $x -le $y ; echo $? a. the number 0 or 1 followed by another 0 or 1 on a new line b. no output c. 1 d. 0 e. test: $x: integer expression expected 6. If a bash shell script named foo contains the line: if [ "$1" = '$2' ] ; then echo SAME ; fi then which of the following command lines will produce SAME as output? a. ./foo '$2' bar b. ./foo bar bar c. ./foo "bar" 'bar' d. ./foo $2 $2 e. ./foo "$1" '$2' 7. How many arguments are passed to the command by the shell on this command line: bar bar bar a. 3 b. 2 c. 4 d. 5 e. 6 8. Given the following bash shell command line: read xx yy zz which user keyboard input line below will assign the text 22 to the shell variable named yy? a. xx=11 yy=22 zz=33 b. 11 22 33 c. 11,22,33 d. 11;22;33 e. 11:22:33 9. Given my directory dir and my file dir/foo owned by me, which permissions allow me to delete the file dir/foo from the directory, but not change the content (data) in the file? a. Permissions 300 on directory dir and 300 on file dir/foo. b. Permissions 300 on directory dir and 500 on file dir/foo. c. Permissions 100 on directory dir and 100 on file dir/foo. d. Permissions 100 on directory dir and 200 on file dir/foo. e. Permissions 500 on directory dir and 400 on file dir/foo. 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-3- PRACTICE 10. What is the output of this command sequence: echo dog >one ; echo cow | head -2 one a. dog b. cow followed by dog c. cow d. an error message e. dog followed by cow 11. If a=cow and b=dog then what is the output of the following sequence of bash commands: [ $a = dog -o $b = cow ] ; echo $? a. no output b. test: $a: integer expression expected c. the number 1 or 0 followed by another 1 or 0 on a new line d. 1 e. 0 12. If foo were a file of text containing 50 different lines, what would be the output of this exact command line: diff foo foo a. an error message because diff doesn't allow the same file name twice b. several lines, which are the lines that are different between the two files c. no output d. the contents of file foo would be displayed e. an error message because diff only allows one file name 13. What is the output of the following sequence of bash commands: x=cow ; y=dog ; test -z $x ; echo $? a. the number 0 or 1 followed by another 0 or 1 on a new line b. test: $x: integer expression expected c. no output d. 1 e. 0 14. How many arguments and options are there to the command: ls -lid /p a. Two arguments, one of which is a single option name and the other is a pathname. b. Three arguments, one of which contains options and one is a pathname. c. Two arguments: A file name starting with a dash and a /p switch option argument. d. Two arguments, neither of which is an option. e. Two command line arguments, one of which contains three options. 15. If cow=5 and dog=5, which bash command sequence correctly compares the two numbers as equal and prints OK? a. if test cow -eq dog ; then echo OK ; fi b. if ( cow == dog ) ; then echo OK ; fi c. if [ $cow==$dog ] ; then echo OK ; fi d. if [ cow = dog ] ; then echo OK ; fi e. if test $cow -eq $dog ; then echo OK ; fi 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-4- PRACTICE 16. What minimal permissions must you have on a directory to be able to execute successfully the command ls . from inside the directory? a. r-- b. r-x c. --x d. -wx e. rw- 17. If the file foo contained the word mom, what would be the bash shell output of this two command sequence: PATH=/etc/passwd:/bin/ls:/bin/cat ; /bin/ls foo a. no output b. /bin/ls: foo: No such file or directory c. mom d. bash: /bin/ls: command not found e. foo 18. If /bin/foo is a program that outputs hi and /usr/bin/foo is a program that outputs mom what is the output of this shell command sequence: PATH=/etc:/usr/bin:/bin ; foo a. bash: foo: command not found b. mom c. hi d. mom followed by hi e. hi followed by mom 19. If a=cow and b=dog then what is the output of the following sequence of bash commands: [ $a = cow -a $b = cow ] ; echo $? a. 0 b. test: $a: integer expression expected c. the number 1 or 0 followed by another 1 or 0 on a new line d. 1 e. no output 20. If dog=12 and cat=99 then which of the following bash command lines outputs only the word hi (and nothing else)? a. [dog!=dog] || echo hi b. [ dog -ne cat ] && echo hi c. [ dog = dog ] && echo hi d. [!dog = cat] && echo hi e. [dog -ne cat] || echo hi 21. If /etc/passwd is a file name, which of the following pathnames always leads to the same file? a. ././etc/passwd b. /etc/passwd/./. c. /etc/../../passwd d. /./../etc/./passwd e. /etc/passwd/../.. 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-5- PRACTICE 22. Which of the following bash PATH statements makes the most sense? a. PATH=/bin:/usr/bin:/etc/passwd b. PATH=/bin/sh:/usr/bin:/etc:/bin c. PATH=/bin/ls:/etc:/usr/bin d. PATH=/bin:/usr/bin:/etc e. PATH=/bin:/bin/cat:/usr/bin 23. What is in the file named file after this command sequence: echo a >x ; echo b >>x ; mv x y >file a. b b. no such file (nonexistent file) c. nothing - file is empty - no data d. a e. a followed by b 24. What is the output of the following sequence of bash commands: false && echo "foo bar $?" a. foo bar 0 b. no output c. foo bar 1 d. foo bar 0 e. foo bar 1 25. What is the output of this sequence of three shell commands: umask 547 ; mkdir newdir ; ls -ld newdir a. d-w--w---- 1 me me 0 Feb 20 07:55 newdir b. d-w--wxrwx 1 me me 0 Feb 20 07:55 newdir c. dr--r--rw- 1 me me 0 Feb 20 07:55 newdir d. dr-xr--rwx 1 me me 0 Feb 20 07:55 newdir e. d-w--wx--- 1 me me 0 Feb 20 07:55 newdir 26. What is the output of the following sequence of bash commands: a=cow ; b=dog ; touch $a ; test -z $a ; echo $? a. the number 1 or 0 followed by another 1 or 0 on a new line b. 1 c. 0 d. test: $a: integer expression expected e. no output 27. Given this long listing: drwxr-xr-x 2048 root root 4096 Jan 20 14:22 /dir How many subdirectories lie immediately under /dir? a. 2048 b. 2046 c. there is not enough information shown to answer the question d. 4094 e. 4096 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-6- PRACTICE 28. If a=cow and b=dog then what is the output of the following sequence of bash commands: if $a = $b ; then echo $a ; fi a. no output b. test: cow: integer expression expected c. bash: cow: command not found d. test: $a: integer expression expected e. cow 29. 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. Type [CONTROL]-[ALT]-[DEL] 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 TAB key. 30. What is the bash shell output of this command sequence: true && echo space junk $? a. no output b. space junk 1 c. space junk ? d. space junk ? e. space junk 0 31. What is the bash output of this command sequence: false && echo "Hello There" a. no output b. "Hello There" c. Hello There d. Hello There e. HelloThere 32. Which bash command line below allows programs in the current directory to execute without preceding the names with ./? a. $PATH=.:$HOME:/usr/bin b. $PATH=/usr/bin:./$HOME c. PATH=./$HOME:/usr/bin d. PATH=/usr/bin/.:$HOME e. PATH=/usr/bin:$HOME:. 33. What is the output of the following sequence of bash commands: x=cow ; y=dog ; touch $x ; test -z $x ; echo $? a. 1 b. no output c. 0 d. test: $x: integer expression expected e. the number 0 or 1 followed by another 0 or 1 on a new line 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-7- PRACTICE 34. If x=pig and y=dog then what is the output of the following sequence of bash commands: if $x = $y ; then echo $y ; fi a. bash: pig: command not found b. test: $x: integer expression expected c. dog d. test: pig: integer expression expected e. no output 35. If foo is a script containing the line TERM=linux ; export TERM, what is the output of the following sequence of bash commands: TERM=vt100 ; ./foo ; echo "$TERM" a. foo b. linux c. $TERM d. vt100 e. TERM 36. 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. '.1* .2*' b. .1 .2 c. .1* .2* d. 11 .1 12 .2 e. $b 37. Which of these statements is true? a. Only single quotes are strong enough to stop shell glob (wildcard) patterns from expanding. b. If /x is an empty directory, sort /x/* produces an error message. c. Typing ./script and bash script always give identical results. d. The cat food command looks up the file name argument food in your $PATH. e. If /y is an empty directory, echo /y/* produces an error message. 38. If variable foo might contain nothing (a null value - defined but empty), which bash command sequence correctly tests for this and prints OK? a. if [ $foo -eq : ] ; then echo OK ; fi b. if [ ''$foo'' = '''' ] ; then echo OK ; fi c. if [ "$foo" = * ] ; then echo OK ; fi d. if [ $foo -eq "" ] ; then echo OK ; fi e. if [ "$foo" = "" ] ; then echo OK ; fi 39. What is the bash shell output of this two-command sequence: cd /home/alleni && echo "In $(pwd)" a. In /home/alleni b. no output c. In $(pwd) d. In 0pwd) e. "In $(pwd)" 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-8- PRACTICE 40. If x=5 and y=5, which bash command sequence correctly compares the two numbers as equal and prints OK? a. if test x -eq y ; then echo OK ; fi b. if test $x -eq $y ; then echo OK ; fi c. if [ x = y ] ; then echo OK ; fi d. if [ $x==$y ] ; then echo OK ; fi e. if ( x == y ) ; then echo OK ; fi 41. 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 of this command: cat foo foo | cat | tail -4 | head -1 a. 6 b. 8 c. 7 d. 9 e. 5 42. What is the output of the following sequence of bash commands: echo wc >wc ; wc wc >wc ; sort wc a. 0 0 0 wc b. 1 1 3 wc c. no output d. 1 1 2 wc e. wc 43. Which command sequence below outputs only lines 11-15 of the Unix password file? a. tail -15 /etc/passwd | head -10 b. tail -10 /etc/passwd | head -15 /etc/passwd c. head -10 /etc/passwd | tail -15 /etc/passwd d. head -15 /etc/passwd | tail -5 /etc/passwd e. head -15 /etc/passwd | tail -5 44. What is the output of the following sequence of bash commands: x=0 ; test $x ; echo $? a. 0 b. 1 c. test: $x: integer expression expected d. the number 0 or 1 followed by another 0 or 1 on a new line e. no output 45. 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. 80 b. no lines (empty file) c. 70 d. 50 e. 120 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-9- PRACTICE 46. What is the bash shell output of this two-command sequence if run in a directory containing 888 files with names that are all the numbers from 1 to 888 inclusive: cow="*" ; echo '$cow' a. '$cow' b. * c. the file names 1 through 888, surrounded by quotes d. $cow e. the file names 1 through 888 47. If variable bar might contain nothing (a null value - defined but empty), which bash command sequence correctly tests for this and prints YO? a. if [ "$bar" = * ] ; then echo YO ; fi b. if [ $bar -eq "" ] ; then echo YO ; fi c. if [ ''$bar'' = '''' ] ; then echo YO ; fi d. if [ "$bar" = "" ] ; then echo YO ; fi e. if [ $bar -eq : ] ; then echo YO ; fi 48. In an empty directory, what is the length of the longest file name created by the following bash shell two-command sequence: x='1 12 123 1234' ; touch '$x' a. 3 characters b. 4 characters c. 1 character d. 2 characters e. 13 characters 49. Given the following bash shell command line: read a b c, which user keyboard input line below will assign the text b to the shell variable named b? a. a=a b=b c=c b. a:b:c c. a;b;c d. a b c e. a,b,c 50. Which of these commands makes a file owned by me, also executable by me? a. umask 111 myfile b. chmod u+x ./myfile c. chmod x=u ./myfile d. umask 777 myfile e. chmod x+u myfile 51. What is the bash shell output of this two-command sequence if run in a directory containing 123 files with names that are all the numbers from 1 to 123 inclusive: bat="*" ; echo "$bat" a. * b. the file names 1 through 123 c. the file names 1 through 123, surrounded by quotes d. $bat e. "$bat" 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-10- PRACTICE 52. Which bash command sequence below always outputs just the date only if the first argument is either a file or a directory? a. if [ -f -o -d "$1" ]; then date ; fi b. if [ "$1" -eq -f -o "$1" -eq -d ]; then date ; fi c. if [ "-f $1" || "-d $1" ]; then date ; fi d. if [ -f "$1" -o -d "$1" ]; then date ; fi e. if [ -f || -d "$1" ]; then date ; fi 53. Which of the following statements is true about this shell command line: >foo file bar haven a. The command file sees three arguments. b. The command file sees two arguments. c. The command foo sees three arguments. d. The command foo sees only two arguments e. Error: The command name is missing from the command line. 54. If directory dir contains only these five two-character file names: a?, 11, ?1, 1*, .1, then which shell command below will remove only the single two-character name ?1 from the directory? a. rm dir/?1 b. rm dir/1* c. rm dir/?? d. rm dir/\?? e. rm dir/*1 55. Which bash command sequence below always outputs just the date only if the first argument is either readable or executable? a. if [ "-r $1" || "-x $1" ]; then date ; fi b. if [ -r -o -x "$1" ]; then date ; fi c. if [ "$1" -eq -r -o "$1" -eq -x ]; then date ; fi d. if [ -r || -x "$1" ]; then date ; fi e. if [ -r "$1" -o -x "$1" ]; then date ; fi 56. If x=8 and y=9 then which of the following bash command lines outputs only the word foobar (and nothing else)? a. [ x = x ] && echo foobar b. [ x -ne y ] && echo foobar c. [x!=x] || echo foobar d. [x -ne y] || echo foobar e. [!x = y] && echo foobar 57. Which bash command sequence correctly searches for the string foo and then prints YES if it is found inside the group file? a. if test foo /etc/group ; then echo YES ; fi b. if [ test foo /etc/group ] ; then echo YES ; fi c. if test foo = /etc/group ; then echo YES ; fi d. if grep foo /etc/group ; then echo YES ; fi e. if [ grep foo /etc/group ] ; then echo YES ; fi 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-11- PRACTICE 58. What is the bash shell output of this two-command sequence if run in a directory containing 765 files with names that are all the numbers from 1 to 765 inclusive: foo="*" ; echo $foo a. * b. the file names 1 through 765 c. all the file names that start with an asterisk ('*') d. an asterisk ('*') and the file names 1 through 765 e. $foo 59. If directory /dir contains these three four-character file names: .123, .124, .???, then what is the output of the following bash shell command line: echo /dir/???? a. /dir/.123 /dir/.124 /dir/.??? b. /dir/.123 /dir/.124 c. /dir/???? d. echo: /dir/????: No such file or directory e. no output 60. What is the output of this sequence of three shell commands: echo x >abc ; ls >abc abc ; wc abc a. 1 1 3 abc b. 1 1 2 abc c. no output d. 0 0 0 abc e. 1 1 4 abc 61. Which bash command line below allows programs in the current directory to execute without preceding the names with ./? a. PATH = ./$HOME:/bin b. $PATH=/bin:./$HOME c. PATH=/bin:$HOME:. d. PATH = /bin:$HOME:. e. $PATH=.:$HOME:/bin 62. Which of the following shell command lines displays all the names in the current directory that are exactly three letters (alphabetic) long (and nothing else)? a. echo [a-mn-zA-YZ][ab-zAB-YZ][za-yZA-Y] b. echo [0-89][01-9][0-45-9] c. echo [a,zA,Z][a,zA,Z][a,zA,Z] d. echo [azAZ][azAZ][azAZ] e. echo ??? 63. If a=cow and b=dog then what is the output of the following sequence of bash commands linked by &&: [ $a = dog -o $b = dog ] && echo $? a. the number 1 or 0 followed by another 1 or 0 on a new line b. test: $a: integer expression expected c. 0 d. no output e. 1 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-12- PRACTICE 64. What is the output of this sequence of three shell commands: umask 674 ; touch newfile ; ls -l newfile a. --------w- 1 me me 0 Feb 20 07:55 newfile b. -rw-rw-r-- 1 me me 0 Feb 20 07:55 newfile c. -rw-rwxr-- 1 me me 0 Feb 20 07:55 newfile d. ---x----wx 1 me me 0 Feb 20 07:55 newfile e. --w--wxr-x 1 me me 0 Feb 20 07:55 newfile 65. How many arguments are passed to the command by the shell on this command line: cow cow a. 3 b. 2 c. 4 d. 6 e. 5 66. Which command line displays the contents of the Unix passwd file one page at a time? a. /etc/passwd | less b. less | /etc/passwd c. cat /etc/passwd >less d. less less 67. If foo is a script containing the line TERM=vt100 ; export TERM, what is the output of the following sequence of bash commands: TERM=linux ; ./foo ; echo $TERM a. foo b. TERM c. vt100 d. linux e. $TERM 68. What is the output of the following sequence of bash commands: cd /bin && echo "cd $(pwd)" a. cd $(pwd) b. bash: cd: /bin: No such file or directory c. no output d. cd /bin e. cd 0pwd) 69. What is the link count of directory dir after this set of successful commands? mkdir dir ; cd dir ; touch one ; mkdir two a. 3 b. 2 c. 4 d. 1 e. 5 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-13- PRACTICE 70. 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. 160 e. 200 71. Which of the following shell command lines displays only the names in the current directory that are exactly three numeric digits long? a. echo [0-9][0-9][0-9] b. echo ??? c. echo '[0-9]''[0-9]''[0-9]' d. echo '0-9'0-9'0-9' e. echo [1-3][1-3][1-3] 72. Which of these statements is true? a. If /p is an empty directory, ls /p/.* produces an error message. b. The ls dir command looks up the directory argument dir in your $PATH. c. If /q is an empty directory, echo /q/.* produces an error message. d. Typing ./script and bash script always give identical results. e. Either single or double quotes will stop shell glob (wildcard) patterns from expanding. 73. Which line below is most likely to be the beginning of an error message? a. echo 2>&1 "... " b. echo 1>&2 "... " c. echo 2>$1 "... " d. echo 2<$1 "... " e. echo 1<&2 "... " 74. A shell script named foo is executed as follows: ./foo a "b c d" e Inside the script is the line: echo "$2" What is the output from this line? a. b b. $2 c. "b d. b c d e. a bash error message: unbound (undefined) variable 75. If a=1 and b=2 then which of the following bash command lines outputs only the word hi (and nothing else)? a. [a!=a] || echo hi b. [a -ne b] || echo hi c. [!a = b] && echo hi d. [ a -ne b ] && echo hi e. [ a = a ] && echo hi 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-14- PRACTICE 76. 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 ../home/me/../etc/passwd ./me/./foo b. cp ../../etc/passwd /me/foo c. cp ./me/../etc/passwd ../home/me/foo d. cp ../etc/passwd ../me/foo e. cp me/../../etc/passwd me/foo 77. Which command sequence below does not generate an error message from the last command in the sequence? a. cat /etc/passwd > mail idallen@ncf.ca b. date >foo ; cp foo/. bar c. mkdir one one/two ; rmdir one/two d. mkdir foo ; ln foo bar e. mkdir foo foo/bar ; rmdir foo 78. If variable cow might contain nothing (a null value - defined but empty), which bash command sequence correctly tests for this and prints OK? a. if [ $cow -eq "" ] ; then echo OK ; fi b. if [ "$cow" = * ] ; then echo OK ; fi c. if [ ''$cow'' = '''' ] ; then echo OK ; fi d. if [ $cow -eq : ] ; then echo OK ; fi e. if [ "" = "$cow" ] ; then echo OK ; fi 79. What is the output of the following sequence of bash commands: x=0 ; y=1 ; touch $x ; test ! -z $x ; echo $? a. the number 1 or 0 followed by another 1 or 0 on a new line b. test: $x: integer expression expected c. no output d. 0 e. 1 80. How many arguments and options are there to the command: cal -yj 1752 a. Two arguments, one of which is a single option and the other is a pathname. b. Two arguments, neither of which is an option. c. A single numeric option and a three-letter file name. d. Two command line arguments, one of which contains two options. e. Three arguments, one of which contains options and one is a pathname. 81. What is the bash shell output of this two-command sequence: cd /home/alleni || echo "In $(pwd)" a. In 0pwd) b. In /home/alleni c. no output d. "In $(pwd)" e. In $(pwd) 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-15- PRACTICE 82. What is the output of the following sequence of bash commands: echo hi >wc ; wc wc >hi ; cat hi a. 1 1 3 wc b. no output c. 0 0 0 wc d. 1 1 2 wc e. hi 83. What is the output of the following sequence of bash commands: echo wc >wc ; wc wc >wc ; cat wc a. no output b. wc c. 0 0 0 wc d. 1 1 2 wc e. 1 1 3 wc 84. Which of these first lines will cause this executable file to be interpreted using the Bash shell? a. !#/bin/bash -u b. !/bin/bash c. #!/bin/bash d. /bin/bash -u e. #/bin/bash 85. 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. :dp b. ddp c. ddP d. DDP e. DDp 86. Select the correct bash shell order of command line processing: a. aliases, redirection, variables, globs b. aliases, variables, globs, redirection c. aliases, globs, variables, redirection d. aliases, variables, redirection, globs e. redirection, aliases, globs, variables 87. If foo is a script containing the line TERM=new ; export TERM, what is the output of the following sequence of bash commands that use foo: TERM=bar ; ./foo ; echo $TERM a. $TERM b. foo c. TERM d. new e. bar 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-16- PRACTICE 88. How many arguments and options are there to the command: wc -l 3 ] ; then echo OK ; fi 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-17- PRACTICE 94. Which command line below does not show any lines from inside the file dog? a. tail dog b. more dog c. ls dog d. head dog e. less dog 95. If bar is an executable script containing the line foo=dog then what is the bash output of this sequence of three commands: foo=cat ; ./bar ; echo "the '$foo' ate" a. the $foo ate b. the '$foo' ate c. the 'cat' ate d. the 'dog' ate e. the 'foo' ate 96. What is the bash shell output of this command sequence: true && echo Hello There $? a. no output b. Hello There 0 c. Hello There ? d. Hello There ? e. Hello There 1 97. What is the bash shell output of this two command sequence: PATH=/bin/ls:/bin/cat:/bin/sh ; cat nosuchfile a. ls: /bin/cat: command not found b. cat: nosuchfile: No such file or directory c. bash: cat: command not found d. bash: /bin/sh: No such file or directory e. bash: /bin/ls: command not found 98. In an empty directory, what is the bash shell output of this three-command sequence: touch aa .a ab .b .c ; x='.a* .b*' ; echo '$x' a. .a* .b* b. aa .a ab .b c. '.a* .b*' d. .a .b e. $x 99. What is the output of the following sequence of bash commands: cd /etc && echo "in $(pwd)" a. in /etc b. in $(pwd) c. bash: cd: /etc: No such file or directory d. no output e. in 0pwd) 100. Which bash command sequence correctly searches for the chars and then prints OK if it is found inside the password file? a. grep chars >/etc/passwd && echo OK b. grep chars >/etc/passwd || echo OK c. grep chars 3 ] ; then echo OK ; fi c. if [ 4 -gt 3 ] ; then echo OK ; fi d. if ( let 4 > 3 ) ; then echo OK ; fi e. if [ ! 4 <= 3 ] ; then echo OK ; fi 106. What is the link count of file foo after this set of successful commands? rm foo ; touch foo ; ln foo bar cp bar x ; ln x y ; ln bar z a. 1 b. 4 c. 5 d. 2 e. 3 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-19- PRACTICE 107. 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. xx xy xz y* b. $a c. x* y* d. xx xy e. *x *y 108. If x=cow and y=dog then what is the output of the following sequence of bash commands: [ $x = cow -a $y = cow ] ; echo $? a. 0 b. no output c. 1 d. the number 0 or 1 followed by another 0 or 1 on a new line e. test: $x: integer expression expected 109. Which of the command lines below can generate a non-empty file? a. sort -r /a/b >/a/b b. tr abc ABC /a/b c. grep -v /a/b /a/b >/a/b d. ls /a/b >/a/b e. tail -5 /a/b >/a/b 110. Which line below passes three separate arguments to the sort command when placed inside a shell script named foo invoked by the command line: ./foo 111 222 333 a. sort "$*" b. sort "$#" c. sort "$1 $2 $3" d. sort "$@" e. sort "$? $? $?" 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-20- PRACTICE Answer Key - DAT2330 - Ian Allen - Fall 2003 - DAT2330 Practice Test - 0% Office use only: 35 39 71 36 30 44 66 63 72 86 8 106 27 51 4 105 87 88 9 55 97 101 85 21 65 23 109 13 108 60 61 16 24 14 46 69 32 5 80 3 41 18 89 28 77 48 7 34 62 91 49 57 83 103 58 56 40 50 84 102 15 75 12 64 67 99 45 26 73 78 76 33 95 37 54 98 90 6 22 53 81 19 17 92 104 110 47 52 43 20 42 96 2 94 79 59 82 70 25 38 93 29 10 31 1 74 68 11 100 107 1. d 49. d 2. d 50. b 3. d 51. a 4. b 52. d 5. d 53. b 6. a 54. d 7. d 55. e 8. b 56. a 9. b 57. d 10. a 58. b 11. d 59. c 12. c 60. e 13. d 61. c 14. e 62. a 15. e 63. c 16. b 64. a 17. e 65. c 18. b 66. d 19. d 67. d 20. c 68. d 21. d 69. a 22. d 70. b 23. c 71. a 24. b 72. e 25. e 73. b 26. b 74. d 27. b 75. e 28. c 76. e 29. e 77. c 30. e 78. e 31. a 79. d 32. e 80. d 33. a 81. c 34. a 82. a 35. d 83. c 36. e 84. c 37. b 85. b 38. e 86. a 39. a 87. e 40. b 88. c 41. a 89. a 42. a 90. c 43. e 91. d 44. a 92. c 45. c 93. d 46. d 94. c 47. d 95. c 48. d 96. b 110 Questions DAT2330 Practice Test - 0% PRACTICE DAT2330 - Ian Allen - Fall 2003-21- PRACTICE 97. c 98. e 99. a 100. e 101. a 102. d 103. e 104. c 105. c 106. e 107. c 108. c 109. d 110. d Count of a: 20 18% Count of b: 17 15% Count of c: 23 21% Count of d: 29 26% Count of e: 21 19% With 5 choices: 110 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 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 Macro .cmd splits: 38 Macro .ans splits: 0 110 Questions DAT2330 Practice Test - 0% PRACTICE