CSCI 243
Midterm Exam
Fall 2007
Instructions:
Write your name in the space provided at the top of the page and answer the
questions below. This exam is closed
book, closed notes, closed neighbor, closed internet, open (hopefully!) minds. Be complete but concise in your answers and
write legibly—if I can’t decipher it, then it’s
wrong! Write your answers in the space
provided. If you need more room, write
them on the back of one of the test pages and leave a note so I’ll know where
to find it. Read through the entire exam
before starting to answer any questions in order to plan your strategy to
maximize your score. There are 100
points on the exam, not counting bonuses, and each question is worth 3
points. You have 50 minutes to complete
it. Good luck and have fun!
I.
UNIX
COMMANDS
a. Write
a Unix command to list all the files in the current
directory, including those whose names begin with a period.
b. Write
a Unix command that renames the file foo to bar (both in the current
directory).
c. Write
a Unix command to list all the processes being run by
user don.
d. Write
a Unix command to change the permissions on file foo in
the current directory to allow read and write access by the owner, read access
by other group members, and no access to anyone else.
e. Write
a Unix command to force a program to end whose process
ID is 15482 and whose parent process ID is 13021.
f. Write
a Unix command that creates an empty file named foo with a time stamp of the
current date and time.
g. Write
a Unix command that compares two files, foo and
bar,
and prints the differences as a series of change commands.
h. What
Unix command allows you to change your password?
i. Write
a Unix command to find all occurrences of the string Linux in files foo and
bar.
j. Write
a Unix command to list all files in the current
directory that start with a lower case a.
k. What
Unix command allows a program to continue running
after you have logged off?
l. What
Unix command lists a file a page at a time, pausing
between pages?
m. What
Unix command displays and allows you to set the date
and time?
n. What
Unix command copies the file foo from
the current directory to the parent of the current directory?
o. If
the current directory is not in your path, what Unix
command runs the program foo which
is in the current directory?
p. What
command displays the number of letters, words, and lines in file bar?
q. What
command lists all the current users who are logged in?
r. What
command runs the program foo in
the background, allowing you to do other tasks in the shell window
concurrently?
s. What
command recursively removes all files and subdirectories (except those starting
with a period) from the current directory?
t. What
command displays the contents of a file as hex values, characters, octal
values, etc?
II.
UNIX
COMMAND SEQUENCES
a. What
command or sequence of commands eliminates duplicate lines in a file? You may rearrange the lines of the file as
needed.
b. What
command sequence creates a file if necessary, and enters the text you type in
the file, all without using a text editor?
c. What
do you type in vi to
replace every occurrence of the word foo with the word bar?
d. What
would you type to run the program foo and capture the output
to the file bar?
e. What
command sequence runs the program foo and the program bar, and uses the output of the
program foo as
input to the program bar?
III.
MISCELLANEOUS
QUESTIONS
a. What
do you type in the input window to abort the program you are running?
b. What
do you type to indicate end of input?
c. What
character indicates the beginning of a line in a regular expression?
d. In lex, how do you specify white space?
e. What
token does the regular expression [a-z_A-Z][a-z_A-Z0-9]*
specify in lex?
f. How
are the three parts of a lex file separated?
g. What
key sequence inserts text at the end of the current line in vi?
h. What
are the three I/O streams that any running program has?
i. In
what programming language is most of the Unix
operating system written?
j. Who
is the creator (and maintainer of the kernel) of the Linux operating system?