Unix Systems Programming: Introductory Lab
Due: Wednesday, October 6, by 5:00 pm.
PURPOSE AND RATIONALE
The purpose of this lab is to quickly get students up to speed with basic
usage of the Unix development environment, as a preparation for all future
lab activities.
PRIMARY RESOURCES:
FAQ(submission instructions and other useful stuffs)
You should refer to relevant sections of the man pages for assistance for
this lab, in addition to materials in your assigned primary texts for this
week.
If possible, you should ssh into the cluster to perform all lab activities.
README
- If you are not in our course email list, please subscribe to the cspp51081
email list here:http://mailman.cs.uchicago.edu/mailman/listinfo/cspp51081
- Turn the lab assignment in by email to the grader by the due date
above.
- For printing out your documents, you might find the following commands
useful during your year(s) in this department:
- lpr - off line print. Note that this command is called
when you print from acroread (for .pdf files) or gv
(for .ps files)
- lpq - shows the printer queue
- lprm - removes jobs from the printer queue
- enscript - converts text files to PostScript (useful when
you want to print out text files)
- Make sure you have read the Homework Style Guidelines for submission.
Introductory LAB
- In your home directory create the subdirectory ~/cspp51081/labs/lab1
. (Use multiple mkdir commands or consult the -p option for mkdir in the
man page for mkdir).
- cd ~/cspp51081/labs/lab1
- Copy or create a file named myfile into ~/cspp51081/labs/lab1
(if you create it, type something into it). For information on how
to create a quick empty file, man touch.
- Create a soft link soft_link and a hard link hard_link
to that file.
- Based on the output returned by stat and ls commands
(using all relevant options), explain in detail (but briefly) the differences
between the three files.
- Read the man pages for the following commands:
- script
- finger, who, w
- touch
- top
- mkdir
- umask: umask [value] (shell built in command)
- text utilities: sort, uniq, tr, expand, unexpand, cut, grep
.
The objective of this exercise is to demonstrate in a reasonably small (the
smaller the better) number of commands that you understood how to use the
commands above and when they are useful.
Create a transcript that shows you understand the commands listed above.
By transcript, I mean a file that shows the output of your session.
See this
example. Yours will be longer. You can use the script
command to create the transcript, or you can cut and paste, whatever works
for you. In your transcript file please show:
- How many John's (first name) have user accounts on the department's computers
[a single pipeline of 3 processes]. Hint: use grep, also look at
wc.
- Show the jobs in the printer queue. [3 characters if you're lucky]
(What printer is your default printer, by the way? See it also with echo
$PRINTER. No need to show this in the transcript)
- Change your file permission mask such that by default your colleagues
do not have read permissions for your newly created files. Please show in
the transcript file the following:
- the initial mask
- how you changed it
- show that people in your user group don't have read permissions
for a new file you're creating.
Change the umask permanently by placing the umask ... command in your .bash_profile
file.
- List the PIDs of all processes running as root on your computer
on a line, separated by commas. E.g.,: 1,2,3,4,5,657,658, ... Use pipes to
create a one-line command that accomplishes this. You'll need some of the
text processing tools presented in class. Hint: man ps (-a and -x flags),
man tr.
- List the usernames and names of the people logged on foster.cs.uchicago.edu
. (NOTE: you may find the command option of ssh
helpful.) The list returned should be sorted, should not contain duplicates
(e.g., same user listed multiple times) and should have the following format:
1 <username1> <name1>
2 <username2> <name2>
3 <username3> <name3>
...
Hints: use the "nl" command to number lines.
- Explain in English what information you can get about ~mark/pub/51081
using all (and only) relevant options of ls and stat commands:
(is it a file? a directory? how large? permissions? access info? etc.) Indicate
the fields that reveal these pieces of information.
More information:
GNU
text utilities (renamed "GNU coreutils")
Hobbes' Internet
Timeline (just for fun)
Brian Martin