SENECA COLLEGE OF APPLIED TECHNOLOGY SCHOOL OF COMPUTER STUDIES FINAL EXAMINATION SUMMER 2002 OPERATING SYSTEMS - UNIX UNX122 STUDENT NAME : ________________________________________ STUDENT NUMBER: _____________________________ SECTION: _______________________________________ DATE: MONDAY AUGUST 12, 2002 TIME ALLOWED: 2 HOURS QUESTIONS PART A PART B PART C PART D PART E MULTIPLE CHOICE XWINDOWS / KDE UNIX COMMANDS SHORT ANSWERS FILE MANAGEMENT 20 MARKS 15 MARKS 20 MARKS 10 MARKS 15 MARKS TOTAL MARKS 80 PROFESSOR (S): Jim Chow / Murray Saul, Gordon Ma / David Ward SPECIAL INSTRUCTIONS: 1. AIDS: ONE 8 ½ x 11 INCH REFERENCE SHEET (HAND-WRITTEN,BOTH SIDES) 2. ANSWER ALL QUESTIONS ON THE EXAM PAPER. SECTION 8.9 OF SENECA COLLEGE ACADEMIC POLICY: CHEATING: is an offence, which will not be tolerated by the College. Such offences occur when a student violates the procedures governing the administration of examinations, tests or other means of evaluating student achievement in a subject or program. APPROVED BY: UNX122v1 ______________________________ VAL FREEMAN, CHAIR Page 1 of 13 pages PART A – MULTIPLE CHOICE 20 MARKS Choose by circling the best answer for each question (circle only 1 answer). One point will be awarded for each correct answer. 1. If your telnet session in Matrix is not working properly, you should set the terminal emulation setting to: a) b) c) d) xterm ascii vt100 vt52 2. To search for short descriptions and manual names for the Unix command containing the keyword “chat”, you issue the Unix command: a) b) c) d) man man man man chat –k chat –s chat –f chat 3. Which of the following Unix commands will provide information regarding a process that you wish to terminate? a) b) c) d) ps process <CTRL><c> kill -9 4. Which of the following are features of the Unix OS? a) b) c) d) Allow more that one person to communication with the computer. Allow users to share or restrict access to their files. Allow a routine series of Unix commands to be run automatically as shell scripts. All of the above are features of the Unix OS. 5. Assuming that the user is currently in their home directory, which of the following Unix commands will copy the entire contents of the user’s home directory (including subdirectory contents) to a directory called ~/backup? a) b) c) d) copy ~ ~/backup cp –r ~ ~/backup cp . ~backup Both a and b UNX122v1 Page 2 of 13 pages PART A – MULTIPLE CHOICE 20 MARKS 6. Which of the following Unix commands will change permissions for all files contained in the directory pathname ~/unx122/samples to allow full permissions for the user, read and execute permissions for group and others? a) b) c) d) chmod chmod chmod chmod 711 755 755 766 ~/unx122/samples ~/unx122/samples ~/unx122/samples/* ~/unx122/samples 7. Which of the following Unix commands will display lines 3 to 7 of a 10 line file called fun that is contained in your current directory? a) b) c) d) head –7 fun | tail -5 tail –8 fun | head -5 both b and c cat fun | head -5 8. What will happen if the following Unix command is issued: sort | tail +25 > abc a) The last 25 lines (sorted in alphabetical order) will be stored in file abc (overwriting previous contents. b) The last 25 lines (sorted in alphabetical order) will be appended to file abc. c) Lines 25 to the bottom of the file will be appended to file abc. d) Nothing will immediately happen. 9. The octal number 7325 represents ______________ as a binary number. a) b) c) d) 111011010101 111001010100 111111010110 111000110111 10. Assume that the following Unix commands have just been issued: umask 127 touch myfile What are the permissions for the file myfile that was just created? a) b) c) d) r r r r UNX122v1 – w w x x – r r r r – – - x x - - - x - Page 3 of 13 pages PART A – MULTIPLE CHOICE 20 MARKS 11. Assuming that you are in the vi editor in command mode, which of the following commands will abort the current editing session? a) b) c) d) Q :q ZZ :q! 12. Which of the following Unix commands will display all lines in the file called report that begin with 3 numbers? a) b) c) d) egrep egrep egrep egrep “$[0-9][0-9][0-9]” report “[1-9][1-9][1-9]$” report “^[0-9][0-9][0-9]” report “^[^a-zA-Z][^a-zA-Z][^a-zA-Z]” report 13. Which of the following key-combinations will open a run dialog box within KDE? a) b) c) d) <ALT><r> <ALT><F3> <ALT><F2> <CTRL><ESC> 14. Which of the following key-combinations will move to the next virtual desktop (in descending order)? a) b) c) d) <SHIFT><CTRL><TAB> <CTRL><TAB> <CTRL><f> <CTRL<F1> 15. A Window manager in X-Windows: a) b) c) d) Provides a method to send information via TCP/IP Can run without the X-Windows environment running. Can be used to support a Desktop Manager All of the above 16. Which of the following Linux applications can incorporate text and graphics? a) b) c) d) Dia Abiword vi both a and b UNX122v1 Page 4 of 13 pages PART A – MULTIPLE CHOICE 20 MARKS 17. Which of the following operations use bit-wise operations? a) b) c) d) Changing directory and file permissions. Setting up the user mask. Performing mathematical calculations. All of the above. 18. Which of the following Linux applications allow you to manipulate graphics? a) b) c) d) Windows Explorer K-edit Konqueror GIMP 19. What does the term “globbing” mean? a) b) c) d) To erase all contents of a user’s account. Replace or expand wildcard symbols with matched files or directories. Remove all non-empty directories. To break into another user’s account. 20. A shell script can perform the following task(s): a) b) c) d) Is used to automatically run routine Unix commands. Can be used to configure a user’s environment upon login. Is a file that contains Unix commands to achieve a task. All of the above are tasks performed by a shell script. UNX122v1 Page 5 of 13 pages PART B – XWINDOWS / KDE 15 MARKS 1. For each of the following questions, fill in the blank with the appropriate term or description. (4 marks) 1. ______________________________ 3. ______________________________ 2. ______________________________ 4. ______________________________ 2. Fill in the chart with the KDE shortcut key to perform the given operations. (4 marks) Operation Display K menu KDE Shortcut Key Switch among windows Change virtual desktops (descending order) Abort X windows session UNX122v1 Page 6 of 13 pages PART B – XWINDOWS / KDE 15 MARKS 3. For each of the following questions, match the letter in the spaces provided to complete the following tasks. The listing of letters must be in the correct sequence. If you have completed your task, leave the remaining spaces blank. Tasks: a. Copy the value on the calculator application to the K-edit text editor. You can assume that the calculator and the K-edit applications are already open. (2 marks) List of Actions: 2. _________ a. b. c. d. e. f. 3. _________ g. 4. _________ h. i. b. Create an icon on the KDE desktop that will run the program ~/a.out (3 marks) j. 1. _________ k. 2. _________ l. m. n. 1. _________ 3. _________ 4. _________ c. Rename the file grades.html to scores.html. You can assume that both of these files are contained in your current directory. (2 marks) 1. _________ o. p. q. r. s. Press <CTRL><x>. Point and click the application icon. Press <ALT><F3>. Select the execute tab. Press <ALT><F2>. Replace the filename with scores.html in the name dialog box. Enter the command ~/a.out in the command textbox. Type ren grades.html scores.html. Point and click the value contained in the calculator window. Move cursor to desired location within K-edit document and press <CTRL><v>. Point and right-click on the file named index.html. Point and click on OK. Select rename from the context menu. Highlight the value in the calculator window and press <CTRL><c>. Select link to application from the context menu. Press <ALT><TAB> until the K-edit application window is active. Press <CTRL><p>. Press <ALT><F1>. Point and right-click on the desktop. 2. _________ 3. _________ 4. _________ UNX122v1 Page 7 of 13 pages PART C – UNIX COMMANDS 20 MARKS Use the information displayed below to answer questions 1 to 4: cat cars chevy ford volvo ford chevy honda ford chevy ford novass mustang gl ltd nova accord thundbd impala bronco 79 65 78 83 80 81 84 65 83 60 45 102 15 50 30 10 85 25 Show the exact output (what is displayed) by each of the following Unix commands. Assume the file cars is located in your current directory. 1. tail +6 cars (2 marks) 2. egrep (2 marks) “s{2,}” cars 3. grep chevy cars | sort –u (2 marks) 4. sort –nk3 cars (2 marks) UNX122v1 Page 8 of 13 pages PART C – UNIX COMMANDS 20 MARKS For questions 5 to 11, each question must be answered with a single Unix command, without making use of the command separator character ; (semicolon). You can assume that all files are contained in your current directory. 5. Write a single Unix command to save the current date and time into a file called current_date. This file should only contain the current date and time. (1 mark) 6. Write a single Unix pipeline command to display a sorted list of all unique lines in a file called phone_numbers.txt. (2 marks) 7. Write a single Unix pipeline command to display the total number of files begining with a number, but not ending with two numbers. (2 marks) 8. Write a single Unix pipeline command to display only the file-type information for file types called ascii (either uppercase or lowercase – 2 marks) 9. Write a single Unix pipeline command to display the number of times that you are logged into the current server (make certain to use one environment variable - 2 marks) 10. Write a single Unix pipeline command to display only lines 7 to 14 for a file called “input” contained in your current directory (2 marks) 11. Write a single Unix command to display all pathnames containing the utility grep or all pathnames containing manual pages for the grep utility. (1 mark) UNX122v1 Page 9 of 13 pages PART D – SHORT ANSWER 10 MARKS You are required to answer only 2 out of the following 4 questions. Your instructor will answer the questions in order of appearance (including partially answered questions). 1. Complete the following conversion table (show your work). Octal Hexadecimal (5 marks) Binary 257 2. In point form, briefly describe the development of the Unix operating system and how it led to the development of the Linux operating system. (5 marks) UNX122v1 Page 10 of 13 pages PART D – SHORT ANSWER 10 MARKS 3. Explain step by step in terms of stdin and stdout what the following Unix command does: ls –F | grep / | tail +5 >> stuff 4. List and explain 3 features of Unix that makes it different than MS-Windows. (5 marks) UNX122v1 Page 11 of 13 pages PART E – FILE MANAGEMENT 15 MARKS All answers are based on the following tree diagram displayed below. You can assume that your Matrix username is called skywalkr and you will be currently located in the directory called /home/skywalker for each of the following questions. Assume all questions are independent of one another. skywalker and obiwan belong to different groups. Additional Information: /home |- skywalkr Directories are: home, | |-- jedi_manual.txt skywalkr, HOMEWORK1, | |-- rebel.TXT HOMEWORK2, | |-- create_force1.TXT POD_RACER, schedule, | |-- create_force2.c obiwan, and TRAINING. | |-- HOMEWORK1 | |-- HOMEWORK2 | |-- POD_RACER | |-- op_manual.txt | |-- schedule | |-- june.txt | |-- august.txt |- obiwan | |-- create_force1.TXT | |-- light_saber.txt | |-- pointers.c | |-- TRAINING | |-- jedi_mind_trick.txt 1. Write a single Unix command to add the following directory path starting from the POD_RACER directory. (1 mark) POD_RACER |-- MANUALS |-- PARTS |-- FUSION 2. Write a single Unix command to allow the user obiwan to at least read the files in your schedule directory. You can assume you have pass-through permissions in your home and POD_RACER directories. (2 marks) 3. Write a single Unix command to copy all text files (i.e. files that end with an uppercase or lowercase .txt ) in obiwan’s home directory to your home directory. Make certain that you do not accidentally overwrite any of your files. (2 marks) UNX122v1 Page 12 of 13 pages PART E – FILE MANAGEMENT 15 MARKS 4. Write a single Unix command to remove all files and directories in your POD_RACER directory. Make certain to have the system prompt you prior to removing files or directories. (2 marks) 5. Write a single Unix command to create a file in your home directory called pointers_obiwan.c that is a link to the file called pointers.c in obiwan’s home directory. (2 marks) 6. Write a single Unix command to change the file called june.txt to july.txt. (1 mark) 7. Write a Unix pipeline command to display only directory filenames in your current directory. (2 marks) 8. Write a single Unix command to list only directories contained in your home directory that begin and end with two letters (either uppercase or lowercase – 2 marks). 9. Write a single Unix command to display the filenames in your current directory with a description of the file type. (1 mark) UNX122v1 Page 13 of 13 pages