Name: __________________________

 

Lab 2 Day-to-Day Work Under UNIX

 

In this lab we will focus on how to do some day-to-day work under UNIX, including some things that will help you communicate problems with me or the TA.

 

Part I: Space Management

 

By default your UNIX account only has 5 Megabytes of space for you to use. This can quickly become filled up, especially if you have logged into a Solaris machine or UNIX machine in one of the computer labs and used Netscape.

 

To check how much space you have left of your 5MB quota, we can query the filesystem with the command fs:

 

fs listquota

 

This can also be abbreviated as:

 

fs lq

 

which reports for me:

 

Volume Name                   Quota      Used %Used   Partition

u.jrmst106                    20000     13687   68%         68%

 

(I have a 20MB quota; yours will say 5000 most likely.)

 

If your %Used is particularly close to 100% (or even a bit over) you may not be able to make any new files. A warning message will also display next to the output from fs lq.

 

We can now check for a Netscape cache directory, which often fills up a quota very quickly. In your home directory execute the following command:

 

ls -alh

 

This is the normal LiSt command with three switches enabled.

 

a

Display all files, including those “hidden” NOTE: Hidden files and directories in UNIX start with a period (.)

l

Display in a columnar list with more information including the size of the file

h

Display sizes in human-readable format (i.e. display 5000 as 5K)

 

In the listing produced, look for a directory named “.netscape” If you have a .netscape directory it is likely using a lot of your quota. Remove it by CAREFULLY typing the following. A typo here could be disastrous (and read the note following the command first.)

 

rm -r .netscape

 

I would type this by typing rm -r .n then hitting TAB to autocomplete the name. An accidental space after the dot will delete your entire home directory and you will have to get it restored by CSSD.

 

Redoing a fs lq now shows:

 

Volume Name                   Quota      Used %Used   Partition

u.jrmst106                    20000     12850   64%         68%

 

So I freed up 4% of my quota from that one directory.

 

You can use ls -alh  and fs lq to help you track down other large files that you might not need to clean up space. Generally, for this class, I’d anticipate not needing more than 1 MB free (80% used.)

 

Part II: Manual Pages

 

If you ever want to see how a command works or you forget the various options you could use, you can consult the “man pages” on the command by typing:

 

man COMMAND

 

for example:

 

man ls

 

This will let you scroll through the online help about the ls command. The SPACE BAR will scroll the document one screenful at a time and the ENTER key will move one line at a time. At any time you can quit by pressing “q

 

 In the space below, explain the purpose of the -S switch (capital S, not lowercase.)

 

1.)

 

 

 

 

 

 

Part III: Recording your work with script

 

Sometimes something will go awry in your program and you may not know the source of an error message from the compiler. For us to help you, we need to see the output of the compiler. We can capture that with a program called script.

 

Type:

 

man script

 

now to read up on how it works.

 

Now open the lab1.c file from your first lab by navigating to it and then opening it in pico. Remove the semicolon after the printf() statement and save.

 

Now issue the script command.

 

script

 

Then compile the modified program.

 

gcc lab1.c

 

This should result in an error message.

 

Type CTRL + D to stop script from recording. If you do an ls now, you should see a file named typescript.

 

We can use the program called more to display the contents of this file. more is also used on the man pages, and can be operated in the same way. If the file is longer than the screen, it will allow you to scroll or to quit at anytime. Type:

 

more typescript

 

to see the output you saw when you compiled the first lab.

 

Part IV: Using pine to send and read email

 

Now that you have the output captured, you can send it as an attachment to an email to the TA or the Instructor. To send email under UNIX we will use a program called pine. Pine is an acronym that stands for “Pine is Not ELM.” Elm is another email program that stands for “electronic mail.”

 

Still in the directory with your typescript, type:

 

pine

If a welcome message appears, dismiss it with ENTER. It will then ask for your login name, which should already be there and correct, so accept it with ENTER. Now at the password prompt, enter your login password again.

 

At the menu screen you can select the folder list option by hitting L or selecting it with the arrow keys and hitting ENTER. You can then select INBOX and hit enter to get your current mail.

 

  1. Hit C to compose a new email.
  2. In the To: field type jmisurda@cs.pitt.edu  
  3. Hit TAB to go to the CC: field
  4. Hit TAB again to go to the attachment field
  5. Hit CTRL + J to attach a file
  6. Hit CTRL + T to browse to the typescript file you saved in the last part.
  7. Hit S to select that file
  8. You can use ENTER to dismiss the attachment comment if it asks.
  9. Use TAB to go to the subject line and type “CS 132 Lab 2”
  10. TAB into the message body and make sure you put your name and login.
  11. When you are finished, hit CTRL + X to send.

 

Show me your response to question 1, and you are done.