DAT2330 Practice Test - Ian Allen - Winter 2003 49 minutes Evaluation: 49 Questions Name: _________________________ Important Instructions 1. Read all instructions and both sides of the page. 2. Manage your time when answering questions on this test. Answer the questions you know, first. _________________________________________________________________ Multiple Choice - 49 Questions (Office use only: 43 24 20 25 42 35 38 17 34 37 13 14 27 1 8 29 45 33 15 18 11 21 26 16 36 19 5 4 49 7 22 10 40 3 12 46 28 2 9 30 41 44 32 39 31 23 6 48 47) 1. Given my directory /a/b and my file /a/b/c owned by me, which permissions allow me to change or create new content (data) in the file /a/b/c but not delete the file? a. Permissions 200 on directory /a/b and 200 on file /a/b/c. b. Permissions 100 on directory /a/b and 200 on file /a/b/c. c. Permissions 100 on directory /a/b and 100 on file /a/b/c. d. Permissions 600 on directory /a/b and 700 on file /a/b/c. e. Permissions 400 on directory /a/b and 400 on file /a/b/c. 2. What command can you use to remove a directory that isn't empty? a. deldir -r dir b. mv -r dir c. rm -r dir d. rmdir -r dir e. del -r dir 3. If /foo/bar were a file of text containing ten different lines, what would be the output of this exact command line: diff /foo/bar /foo/bar a. the contents of file /foo/bar would be displayed twice b. no output c. several lines, which are the lines that are different between the two files d. an error message because diff only allows one file name e. an error message because diff doesn't allow the same file name twice 4. If I have a directory owned by me named /a/b/c/d, which of the following actions would increase its link count by exactly one? a. create one subdirectory named /a/b/c/d b. create one subdirectory named /a/b/c/d2 c. create one subdirectory named /a/b/c/d/e d. create one file named /a/b/c/d/e e. create one file named /a/b/c/d2 49 Questions DAT2330 Practice Test - 0% 45 minutes DAT2330 - Ian Allen - Winter 20-2- 45 minutes 5. What would you type to change the permissions on a file to rw-r--r--? a. chmod 211 file b. chmod 311 file c. chmod 644 file d. chmod 344 file e. chmod 244 file 6. 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/a* b. rm /a? c. rm /a/a? d. rm /a/a[*] e. rm /a/a\? 7. What is the bash shell output of this two command sequence: PATH=/dev/null:/bin/ls:/bin/cat ; ls nosuchfile a. ls: nosuchfile: No such file or directory b. bash: /dev/null: No such file or directory c. bash: ls: command not found d. bash: /bin/cat: command not found e. ls: /bin/ls: command not found 8. What would you type to find the string tony in the file /etc/passwd? a. file /etc/passwd tony b. grep tony >/etc/passwd c. grep /etc/passwd tony d. file tony /etc/passwd e. grep tony /etc/passwd 9. 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 [0-3][0-3][0-3] d. echo [?][?][?] e. echo [a-zA-Z][a-zA-Z][a-zA-Z] 10. Which of the command lines below can generate a non-empty file? a. sort /a/b >/a/b b. diff /a/b /a/b >/a/b c. tr abcd 1234 /a/b d. wc -l /a/b >/a/b e. head -5 /a/b >/a/b 11. When using the links text-only web browser on Linux, what command letter lets you type in a URL to go to? a. a b. s c. d d. g e. q 49 Questions DAT2330 Practice Test - 0% 45 minutes DAT2330 - Ian Allen - Winter 20-3- 45 minutes 12. What is the Unix user name for the Super-User account? a. master b. root c. superuser d. alterego e. administrator 13. Which of the following is true, given this long directory listing: drwxr-x--x 71 ian user 4096 May 30 12:35 /dirname a. The number 4096 is the inode number of this directory. b. The number 71 is the count of links (names) this directory has. c. The number 4096 is the count of links (names) this directory has. d. The number 71 is the size of this directory. e. The number 71 is the inode number of this directory. 14. What do you do on Floppix/Linux/Unix to erase an entire line of typing? a. select the line with the mouse and use the BACKSPACE key b. type [CTRL-U] c. select the line with the mouse and use the DEL key d. type [CTRL-D] e. type [CTRL-W] 15. What Unix command line will show you all of the processes currently running, for all userids? a. whereis ps b. finger ps c. ps all d. which ps e. ps aux 16. 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 3 /a/b/x c. 1 1 2 /a/b/x d. 1 1 1 /a/b/x e. 0 0 0 /a/b/x 17. Given my directory /a/b and my file /a/b/c owned by me, which permissions allow me to delete the file /a/b/c from the directory, but not change the content (data) in the file? a. Permissions 100 on directory /a/b and 200 on file /a/b/c. b. Permissions 300 on directory /a/b and 300 on file /a/b/c. c. Permissions 500 on directory /a/b and 400 on file /a/b/c. d. Permissions 100 on directory /a/b and 100 on file /a/b/c. e. Permissions 300 on directory /a/b and 500 on file /a/b/c. 49 Questions DAT2330 Practice Test - 0% 45 minutes DAT2330 - Ian Allen - Winter 20-4- 45 minutes 18. 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. 80 c. 20 d. 50 e. no lines (empty file) 19. Which command line below does not show any lines from inside the file dog? a. more dog b. head dog c. less dog d. tail dog e. ls dog 20. What does the -v option to the grep command do? a. selects lines that do not contain unprintable characters b. prints the version number of the grep command c. turns on the translation of unprintable characters d. selects lines that do not contain a match for the supplied pattern e. turns off the translation of unprintable characters 21. Which of these statements about the telnet terminal emulator is true? a. telnet doesn't require you to log in to the remote computer b. you can use telnet to connect from your Unix system back to your own Unix system c. you can only use telnet to connect to a different computer d. you can only use telnet to connect to machines on the local network e. you must give a computer name, not a number, as an argument to telnet 22. What minimal permissions must you have on a directory to be able to execute successfully the command ls . from inside the directory? a. -wx b. r-x c. rw- d. r-- e. --x 23. Which of these statements is true? a. You can make a hard link to a directory. b. If you give me write permission on a file owned by you, I can then use chmod to change its permissions. c. You only need "r--" permission on directory "foo" for "ls -l foo" to work. d. To make a hard link to file "foo" named "bar", file "foo" must exist. e. The "ln" command takes two arguments, so the maximum number of hard links a file can have is two. 49 Questions DAT2330 Practice Test - 0% 45 minutes DAT2330 - Ian Allen - Winter 20-5- 45 minutes 24. Which command line displays the contents of the Unix passwd file one page at a time? a. cat /etc/passwd >more b. /etc/passwd | more c. more /etc/passwd d. more | /etc/passwd e. /etc/passwd >more 25. 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/.aa /a/b/.ab /a/b/.a? /a/b/.a* b. /a/b/??? c. /a/b/.a? d. no output e. /a/b/.aa /a/b/.ab 26. Which command removes adjacent duplicate lines from a file? a. dupl b. unique c. dup d. duplicate e. uniq 27. How many arguments and options are there to the command: cal -jy 2001 a. Two command line arguments, one of which contains two options. b. Two arguments, one of which is a single option and the other is a pathname. c. Two arguments, no options. d. Two options, no arguments. e. A single numeric option and a three-letter file name. 28. Which of these statements is true? a. The file command creates a new, empty file in the current directory b. To indicate End-of-File (no more input) to a program, type [CONTROL]-[D]. c. To interrupt a Unix process from the keyboard, type [CONTROL]-[D]. d. To telnet to ACADAIX from outside the College, use the name acadaix.algonquin. e. To erase an entire line of typing, type [ALT]-[DELETE]. 29. Which of these statements is true? a. The ls command looks up a command line argument (ls dir) in your $PATH. b. Typing ./script and sh script always give identical results. c. Shell glob (wildcard) patterns are expanded after shell variables are expanded. d. If /x is an empty directory, ls /x/.* produces an error message. e. If /y is an empty directory, echo /y/.* produces an error message. 49 Questions DAT2330 Practice Test - 0% 45 minutes DAT2330 - Ian Allen - Winter 20-6- 45 minutes 30. How can you ask the bash (Linux) shell to complete commands or file names for you? a. You can type the first part of the command or file name and press the TAB key. b. Type [CONTROL]-[D] and the shell will present a menu of commands. 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. 31. When doing an ls -a, the output pathname that is a double dot (..) signifies what? a. The parent directory. b. The current directory. c. A hidden file. d. A file or directory with double links. e. The root directory. 32. What is true when you use the telnet program to start a session to a remote computer? a. your work is done on the local system and copied to the remote system b. all of your work is done on the remote system c. commands are executed on the local system d. files are created and destroyed on the local system e. your local computer acts as a server for the remote computer 33. Which of these statements is true? a. The cat command looks up a command line file name argument (cat filename) in your $PATH. b. If /a is an empty directory, echo /a/* produces an error message. c. Typing ./script and sh script always give identical results. d. If /a is an empty directory, cat /a/* produces an error message. e. Shell glob (wildcard) patterns are expanded before shell variables are expanded. 34. Which of these statements is true? a. To indicate End-of-File (no more input), type [CONTROL]-[E]. b. Unix commands must be entered in lower-case letters. c. To erase an entire line of typing, type [CONTROL]-[E]. d. You can only login to Unix once per userid; you cannot be logged in to the same machine twice. e. Unix commands can be entered in upper-case or lower-case letters; they are equivalent. 49 Questions DAT2330 Practice Test - 0% 45 minutes DAT2330 - Ian Allen - Winter 20-7- 45 minutes 35. What ftp userid do you use to download software using "anonymous ftp"? a. software b. anonymous c. public d. use your Algonquin userid e. download 36. Which of the following bash PATH statements makes the most sense? a. PATH=/etc:/usr/bin:/bin/ls b. PATH=/bin:/usr/bin:/etc/motd c. PATH=/etc/.:/usr/bin:/bin d. PATH=/bin:/usr/bin:/etc/passwd e. PATH=/usr/bin:/etc:/bin/cat 37. 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. 96 b. 96 96 c. 98 d. 04 04 e. 01 01 38. What can you do to get back (redo) the last command you typed to the bash (Linux) shell? a. Type [ALT]-[F2] b. Type [CONTROL]-[BACKSPACE] c. Use the "UpArrow" key. d. Use the "PageUp" key. e. Type [CONTROL]-[ALT]-[DEL] 39. What does the Floppix mail command take as a command line argument? a. a userid b. a message number c. the Floppix mail command does not accept any arguments d. a file name to send by email e. a date 40. Which of the following statements is true about this shell command line: sorted-users b. who | sort >sorted-users | tee on-users c. who | sort sorted-users | tee on-users d. who | tee on-users | sort sorted-users e. who | tee >on-users | sort >sorted-users 42. Which of these statements is true? a. Typing ./script and sh script always give identical results. b. Shell glob (wildcard) patterns are expanded before shell variables are expanded. c. The cat command looks up a command line file name argument (cat filename) in your $PATH. d. If /a is an empty directory, echo /a/* produces an error message. e. If /a is an empty directory, cat /a/* produces an error message. 43. 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. no lines (empty file) b. 160 c. 50 d. 80 e. 30 44. Which of the following bash PATH statements makes the most sense? a. PATH=/bin:/bin/ls:/etc/motd:/usr/bin b. PATH=/bin:/usr/bin:/etc/passwd c. PATH=/bin/sh:/usr/bin:/etc d. PATH=/bin/ls:/etc:/usr/bin e. PATH=/etc:/usr/bin:/bin 45. Which of the command lines below can generate a non-empty file? a. sort -r /a/b >/a/b b. tail -5 /a/b >/a/b c. tr abc ABC /a/b d. grep -v /a/b /a/b >/a/b e. ls -i /a/b >/a/b 46. What would you see if you typed this command: cat /users a. The contents of the file users located in the parent directory b. The contents of the file users located in your home directory c. The contents of your directory named users d. The contents of the file users located in the root directory e. The contents of your subdirectory named users 49 Questions DAT2330 Practice Test - 0% 45 minutes DAT2330 - Ian Allen - Winter 20-9- 45 minutes 47. How many arguments and options are there to the command: ls -al /etc a. Two arguments, one of which is a single option and the other is a pathname. b. Two options, no arguments. c. Two arguments, no options. d. A three-letter file name and an /etc switch option. e. Two command line arguments, one of which contains two options. 48. Which command line below will place the output of script ./myscript into a file named party and place a word count of the same output in a file named wc? a. ./myscript | tee party | wc wc b. ./myscript >wc wc | tee party c. ./myscript | cat >party | wc >wc d. ./myscript | tee party | >wc wc e. ./myscript | cat >party | wc >wc 49. If /a/b were a readable empty file, what would be the bash shell output of this two command sequence: PATH=/etc/passwd:/bin/ls:/bin/cat ; /bin/cat /a/b a. /bin/cat: /a/b: No such file or directory b. bash: ls: command not found c. no output d. bash: /bin/cat: command not found e. bash: cat: command not found 49 Questions DAT2330 Practice Test - 0% 45 minutes DAT2330 - Ian Allen - Winter 20-10- 45 minutes Answer Key - DAT2330 - Ian Allen - Winter 2003 - DAT2330 Practice Test - 0% Office use only: 43 24 20 25 42 35 38 17 34 37 13 14 27 1 8 29 45 33 15 18 11 21 26 16 36 19 5 4 49 7 22 10 40 3 12 46 28 2 9 30 41 44 32 39 31 23 6 48 47 1. b Count of a: 5 10% 2. c Count of b: 12 24% 3. b Count of c: 10 20% 4. c Count of d: 10 20% 5. c Count of e: 12 24% 6. e 7. c With 5 choices: 49 8. e 1 2 3 4 5 6 7 8 9 10 11 12 13 9. e 14 15 16 17 18 19 20 21 22 23 10. d 24 25 26 27 28 29 30 31 32 33 11. d 34 35 36 37 38 39 40 41 42 43 12. b 44 45 46 47 48 49 13. b 14. b Macro .cmd splits: 9 15. e Macro .ans splits: 0 16. e 17. e 18. d 19. e 20. d 21. b 22. b 23. d 24. c 25. b 26. e 27. a 28. b 29. c 30. a 31. a 32. b 33. d 34. b 35. b 36. c 37. c 38. c 39. a 40. d 41. a 42. e 43. d 44. e 45. e 46. d 47. e 48. d 49. c 49 Questions DAT2330 Practice Test - 0% 45 minutes