=========================preview======================
(COMP111)comp111_99s_midterm_sol.pdf
Back to COMP111 Login to download
======================================================
COMP111: Software Tools
Midterm Exam
Spring 1999
24 March 1999
Student Name: _______________________________________________
Student Number: _____________________________________________
Lab Section: ________________________________________________
TA: _________________________________________________________
Instructions:
1.
There are 28 problems worth 100 points total.
2.
Check that you have all 13 pages.
3.
Answer all questions in the space provided. Rough work can be done only on the back pages..
4.
Leave all pages stapled together.
5.
The examination period will last for 120 minutes.
6.
Stop writing immediately when the time is up.
For Grading Purposes Only:
Page 2: Problems 1-3 ______________ / 9
Page 3: Problems 4-6 ______________ / 7
Page 4: Problems 7-9 ______________ / 9
Page 5: Problems 10-12______________ / 13
Page 6: Problem 13 ______________ / 5
Page 7: Problem 14 ______________ / 7
Page 8: Problem 15 ______________ / 5
Page 9: Problems 16-18______________ / 9
Page 10: Problems 19-21______________ / 9
Page 11: Problems 22-24______________ / 8
Page 12: Problems 25-27______________ / 12
Page 13: Problem 28 ______________ / 7
Total: ______________ /100
COMP111 Spring 1999 HKUST 1 of 13
1) (5 points) Command identification:
a) What command lists the first 15 lines of the file letter1 in the current directory?
Answer: head -15 letter1
b) What command lists the last 15 lines of the file letter1 in the current directory?
Answer: tail -15 letter1
c) What command tells who is the user?
Answer: whoami
d) What command tells the current working directory?
Answer: pwd
e) Which command can stop a background job?
Answer: kill
2) (2 points) A file called namescontains the following text:
Mr. Bill
Bill Gates
Jackie Chan
President Woo
Bill Gates
Dr. Andrew Horner
President Bill Clinton
What is displayed on the screen after executing the following pipeline?
$ sort names | grep Bill | uniq | grep G Answer: Bill Gates
3) (2 points) What is wrong with the following command? $ cat file1 >file2 | sort >file3
Answer: cat has two outputs! (>file2 and the pipe) Illegal, can only have one output.
COMP111 Spring 1999 HKUST 2 of 13
$ whoami
gates
$ pwd
/homes/gates
$ cd ..
$ cd ~
$ cd .
Answer: ~gates or: /homes/gates
5) (2 points) What is wrong with the following group of commands?
$ whoami
clinton
$ pwd
/homes/clinton
$ ls -l ~horner/111
2 -rw------- 1 horner cs 154 Feb 4 16:38 file1
2 -rw------- 1 horner cs 64 Feb 4 15:00 file2
2 drwxr-xr-x 2 horner cs 512 Feb 8 18:01 dir1/
$ cp ~horner/111/file1 ~clinton
Answer: We cant copy file1 because clinton (who is not the owner) does not have read permission for this file.
6) (3 points) What command(s) would you use to set the permission of the file letter1so that the owner has only read and write permission, "group" has only read permission, and "other" has no permission? (