CS 497C - Mid-Term Exam - Name: ____________ Date: Friday, October 19 (in class) Part 1: (44 points - 4 points for each problem) (2) 1. Which part of the operating system gets loaded into memory as soon as the system is booted? (1) shell (2) kernel (3) file (4) process (3) 2. What command is generally used to end an input session? (1) Ctrl-z (2) Ctrl-q (3) Ctrl-d (4) Ctrl-l (2) 3. If the {\bf apropos} command is not available, which command can you use? (1) man -l (2) man -k (3) man -f (4) man -c (4) 4. How do you delete text from the current line to the beginning of the file in vi? (1) 1GdG (2) dG (3) d0G (4) d1G (1) 5. How do you globally replace Internet with Web occurring in all lines using vi? (1) :1,\$s/Internet/Web/g (2) :1,\$s/Internet/Web (3) :.,\$s/Internet/Web/g (4) :.,\$s/Internet/Web (1) 6. How can you quit emacs? (1) [Ctrl-x][Ctrl-c] (2) [Ctrl-x][Ctrl-f] (3) [Ctrl-x][Ctrl-q] (4) [Ctrl-x][Ctrl-s] (3) 7. What command is used to interactively delete files? (1) rm (2) rm -d (3) rm -i (4) rm -a (3) 8. What command is used to rename a file? (1) ren (2) rename (3) mv (4) newname (2) 9. How would you display all files including hidden ones in columns and identify directories and executables? (1) ls -lat (2) ls -Fax (3) ls -tar (4) ls -Rak (3) 10. What is equivalent to chmod 711 file? (1) chmod u=rw,go=x file (2) chmod u=rw,go=rx file (3) chmod u=rwx,go=x file (4) chmod u=rwx,go=rx file (4) 11. How do you symbolically link /usr/games/netris with a file of the same name in your current directory? (1) ln . /usr/games/netris (2) ln /usr/games/netris . (3) ln -s . /usr/games/netris (4) ln -s /usr/games/netris . Part 2: (56 points) 1. What is an operating system? List three different operating systems. (6 points) Ans: (1) An operating system (sometimes abbreviated as "OS") is a program that functions as a virtual machine (layer of software on top of bare hardware) and a resource manager (software that controls access to computer). (2) DOS, Windows, Mac OS, and UNIX. 2. What is PATH? How do you evaluate its value? (6 points) Ans: (1) PATH is a system variable which stores a lists of directories that the shell searches to locate a command. (2) Use echo $PATH to evaluate its value. 3. Name three ways of quitting vi and saving the file. (6 points) Ans: Use the command :x, :wq, or ZZ to save and quit the vi editor. 4. How do you mark a region, copy it, and put it in the new location in emacs? (5 points) Ans: Mark the beginning of the region by [Ctrl-Spacebar] or [Ctrl-@] and move the cursor to the end of the region. Copy it by [Alt-w]. Put it by [Ctrl-y]. 5. How does UNIX divide files into three categories? (6 points) Ans: Ordinary file - Also known as regular file. It contains only data as a stream of characters. Directory file - A folder containing the names of other files and directories. Device file - It represents all hardware devices. 6. What directories do . (a single dot) and .. (two dots) represent respectively? (4 points) Ans: . (a single dot) represents the current directory. .. (two dots) represents the parent directory. 7. If mkdir foo doesn't create the directory, what could be the possible reasons? Write at least three possible reasons. (6 points) Ans: (1) The directory foo already exists. (2) An ordinary file with the same name exists. (3) The user doesn't have permission to create it. 8. A file with {\tt -rwxr-x--x} has what permissions assigned to it? (6 points) Ans: Owner: read, write, execute; Group: read, execute; Others: execute. 9. Specify which file attributes change when you copy a file from another user account. (6 points) Ans: (1) The file's owner changes to the user who copys this file. (2) Last modification and access time changes to the time of copy. (3) If the two users are in different groups, the file's group changes. (4) File permissions change to the default permission of the user who copy this file. 10. Use the {\tt find} command to move all files with the html extension (i.e. {\tt *.html}) from the current directory to the htdocs directory under the parent directory. hint: This can be done with the -exec operator, followed by the command to be executed and terminated with the sequence {} \; (5 points) Ans: find . -name "*.html" -exec mv {} ../htdocs \;