Unix Test #1 DAT2330 - Ian Allen - Winter 20-1- 45 minutes Evaluation: 42 Questions Name: _________________________ Important Instructions 1. Read all instructions and both sides of all pages. 2. Manage your time when answering questions on this test. Answer the questions you know, first. (Office use only: 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) 1. What is the output of this shell command line in an empty directory? echo * a. * b. an error message from echo saying * does not exist c. no output d. . .. e. . 2. Which command line below does not show any lines from inside the file out? a. wc out b. head -99 out c. tail out d. sort -n out e. more out 3. What can you do to get back (redo) the last command you typed to the bash (Linux) shell? a. Use the "UpArrow" key. b. Use the "PageUp" key. c. Type [ALT]-[F2] d. Type [CONTROL]-[ALT]-[DEL] e. Type [CONTROL]-[BACKSPACE] 4. What command shows all the lines in file out that contain the string foo? a. grep grep foo d. grep out foo | cat e. grep foo >out 5. Which command sequence outputs inode/filename pairs for names in the current directory, sorted by inode number? a. ls -ai | sort -n b. sort -n | ls -ai c. ls -i * > sort -n d. ls -node * > sort -n e. ls ./* | sort -node 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Winter 20-2- 45 minutes 6. What is in the file bar after this command sequence: echo hi >x ; echo ho >x ; mv x y >bar a. nothing - empty file - no data b. hi followed by ho c. hi d. ho e. no such file (nonexistent) 7. How many lines are in the file bar after this command sequence: echo hi >x ; echo ho >>x ; cat x x >bar a. 4 b. 6 c. 2 d. 1 e. nothing - empty file - no data 8. Which command line lists all possible utilities available for compiling programs? a. apropos compile b. man compile c. grep compile /etc/* d. grep /etc/* compile e. man * | grep compile 9. Which of the command lines below can generate a non-empty file? a. ls -ls file >file b. tr a b file c. awk '{print $1}' file >file d. touch file >file e. uniq file >file 10. In the output of the command ls -a, a dot that begins a name signifies what? a. A name that is hidden. b. The parent directory. c. The current directory. d. A current file. e. A name with an unprintable character. 11. Which command below sorts only this five-character file name containing a special character (and no others): xx?xx a. sort "xx?xx" b. sort xx?xx c. sort xx/?xx d. sort ''xx?xx'' e. sort ""xx?xx"" 12. Which command below removes only this five-character file name containing a special character (and no others): yy?yy a. rm yy\?yy b. rm yy/?yy c. rm yy\\?yy d. rm yy//?yy e. rm yy?yy 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Winter 20-3- 45 minutes 13. If you type the command xload which of the following key sequences will interrupt it and take you immediately back to the command prompt? a. [CTRL-C] b. [CTRL-D] c. [CTRL-L] d. [CTRL-U] e. [CTRL-R] 14. If you type the command tr a b which of the following key sequences will send an EOF and take you immediately back to the command prompt? a. [CTRL-D] b. [CTRL-C] c. [CTRL-L] d. [CTRL-U] e. [CTRL-R] 15. If I am in my home directory named /home/ian and mt is an empty sub-directory, what is true after this command line: who >../ian/cat ; cp ./mt/../cat ./mt/../dog a. the directory mt is still empty b. the directory mt now has a file named dog in it c. the directory mt now contains two files d. there is a second copy of the file named who in the file dog e. the command fails because the path ./mt/../cat does not exist 16. How many command arguments does the shell pass to this echo command: echo 'It's a bird! It's a plane!' a. Four arguments. b. Five arguments. c. One argument. d. Two arguments. e. Three arguments. 17. How many arguments does the shell pass to this echo command: echo " 1 2 " three ' 4 ' five"6" a. Four arguments. b. Three arguments. c. Five arguments. d. One argument. e. Nine arguments. 18. Which of the following is true, given this long directory listing from ls: drwxr-x--x 456 ian user 123 May 30 12:35 dir a. The number 123 is the size in bytes of this directory. b. The number 123 is the count of links (names) this directory has. c. The number 456 is the inode number of this directory. d. The number 456 is the octal permissions of this directory. e. The number 456 is the size of this directory. 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Winter 20-4- 45 minutes 19. 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. cat a >foo ; cat b >>foo b. cp a >foo ; cp b >>foo c. cp a b >foo d. mv a b >foo e. echo a b >foo 20. If my current directory is /bin, which of these pathnames is equivalent to the file name /bin/ls? a. ../../bin/ls b. ../bin/ls/. c. ./bin/ls d. ls/. e. /root/bin/ls 21. What is the output of this successful command sequence? cd /tmp ; mkdir foo ; mkdir bar ; pwd a. /tmp b. /tmp/foo c. /tmp/bar d. /tmp/foo/bar e. /bar 22. Which of the following pathnames always leads to the same file named: /etc/passwd? a. /etc/../etc/passwd b. /etc/./etc/../passwd c. /etc/passwd/. d. ./etc/passwd e. ../etc/passwd 23. How many arguments and options are there to the command: ls -ls /cat 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. A three-letter file name and a /cat switch option argument. d. Two arguments, no options. e. Two options, no arguments. 24. 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. You can type the first part of the command or file name and press the ALT key. c. Push key F1 and the system will present a menu of commands. d. Type [CONTROL]-[D] and the shell will present a menu of commands. e. Type [CONTROL]-[C] and the shell will present a menu of commands. 42 Questions DAT2330 Test #1 - Unix - 15% 45 minutes DAT2330 - Ian Allen - Winter 20-5- 45 minutes 25. Which command below is the best way to find a line containing an asterisk (*) in the file named foo? a. grep '*'