Hands-on 2: The UNIX Time-Sharing SystemBefore attempting this hands-on, you should read The Unix Time-Sharing System, which is also assigned for two recitations. You might also find Section 2.5 of the book useful. WarmupLog into an Athena machine (athena.dialup.mit.edu is ok) and get access to the Athena command prompt. If you logged into an Athena dialup machine, you should see the prompt in your ssh client. If you logged into an Athena workstation you may need to open a terminal window. The prompt should look something like this (the "no-knife" part may say something different): no-knife:~> Use the add command to gain access to the 6.033 utilities you will use in this assignment. no-knife:~> add 6.033 Some of the directions in this hands-on assume your UNIX shell is tcsh. Run the following command to ensure you're running the appropriate shell. After you run tcsh -f your prompt will change to a single >. no-knife:~> tcsh -f We'll start off with a small example: > cd /bin > ls -1 | moreHere, we are first changing into the /bin directory, which contains many of the executable commands for the system. The command ls
-1 gives us a listing of all the files in the current directory
with one file per line. (Note that -1 is the numeral
"one", not the letter "L".) We then pipe the output from
ls to the command more , which displays the
results one page at a time. (Press the space bar to show the next
page. In order to quit the enumeration, press q.) You can refer to the
manual pages for ls and more to see more details
and options for each command. Manual pages let you read information about
various commands on UNIX systems; to use them, run
> man command
where > man manfor information on the man command itself. Keep in mind that the manual pages for basic commands vary from system to system (much as the commands themselves do). Now, try this: > cd /bin > ls -1 | grep p | moreThis runs the same ls -1 command, but only lists the
executable files which happen to contain the letter "p" somewhere in
their names.
The point here is to observe that you can chain together multiple
commands using the pipe character ( Building BlocksNow, we'd like you to figure out on your own how to solve some problems by chaining different commands together. If you aren't already familiar with these commands, you may want to briefly skim through their man pages to familiarize yourself with what they do. You will probably need to use some of the options for the different commands in order to solve these problems. Here are the commands you may find useful: cat fmt grep head ls ps sort tail top wc yes (*)
(*) On some Athena machines, the > add gnu
(If you are curious about Athena's locker system, you can run
Once you have added the gnu locker, you can use III. QuestionsNow you're ready for this week's questions. Like before, the questions are in a read-only google doc. Make sure to enter quesitons in the page indicated and upload them as a PDF to Gradescope. See more detailed instructions at the end of last week's hands-on. If you are having Gradescope questions, please post a question on Piazza! |