=========================preview======================
(COMP111)comp111_01s_midterm_sol.pdf
Back to COMP111 Login to download
======================================================
COMP111: Software Tools
Midterm Exam C Dickson Chiu
Spring 2001 (March 14, 2001 7pm-9pm)
Student Name: _______________________________________________
Student Number: _____________________________________________
Email: ______________________________________________________
Lab Section: ________________________________________________
Instructions:
1.
There are 16 problems worth 100 points total.
2.
Check that you have all 8 pages.
3.
Close book, close notes, work on your own, and you cannot use any computer.
4.
Answer all questions in the space provided. Rough work can be done only on the back pages.
5.
Leave all pages stapled together.
6.
The examination period will last for 120 minutes.
7.
Stop writing immediately when the time is up.
For Grading Purposes Only:
Page 2: Problems 1-3 ______________ / 22
Page 3: Problems 4-7 ______________ / 14
Page 4: Problems 8-9 ______________ / 11
Page 5: Problems 10-11 ______________ / 12
Page 6: Problems 12-13 ______________ / 14
Page 7: Problem 14 ______________ / 10
Page 8: Problems 15-16 ______________ / 17
Total: ______________ /100
1) (18 points) Command Identification. You must use a single command to satisfy your requirement and the command must work whatever your current working directory and home directory are.
Requirement Command
List the first line of the file letter1 in the current directory. head C1 letter1
List all lines except the first line of the file letter1 in the current directory. tail +2 letter1
List the names of all the files in the current directory that begin with a digit and ends with extension .c ls [0-9]*.c
Delete all the files in the current directory with an extension .bak rm *.bak
Copy the whole subdirectory tree junk to a new one called backup (both in the current directory). cp CR junk backup (or Cr)
Delete the whole subdirectory tree junk in the current directory rm CR junk backup (or Cr)
Create a new user peterif you are the administrator. useradd peter
Change the password of the user peterif you are the administrator. passwd peter usermod -p newpassword peter
Create a new group students if you are the administrator. groupadd students
Add peter to the group students if you are the administrator. usermod -G students peter
List the members of the group students ypcat group | grep students
List all the mounted file systems in your UNIX computer df
List the disk usage in number of blocks for the subdirectories in your home directory du ~
List the content of a file called /tmp/dl.tar.gz in gzipped tar format gtar ztvf /tmp/dl.tar.gz gzip Cd Cc /tmp/dl.tar.gz | tar tvf -
send a email to peter@cs.ust.hk with the file called invitation as its content in your home directory. mail peter@cs.ust.hk < ~/invitation
compress the subdirectory directory called send in you home directory in zip format and store it as /tmp/send.zip (so that yo