All pastes #948325 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-03-19 01:10 UTC
rendered paste body
90.311 Midterm Exam   Instructor: Sean McGowan    Spring '07
----------------------------------------------------------------

Please read the following questions carefully and remember to answer all
parts of each question in the space provided. It is easiest for me if you
delete the questions once you have an answer, but if you don't, that is
fine too.  When deriving your answer, be as specific as possible. Please 
feel free to use any paper (books) or electronic (computer) resources, but 
no human (friend who is a unix sys-admin) resources.  This test is supposed 
to test your UNIX knowledge and skill.  If there are any questions regarding 
the midterm, please email me(do not post a message on the discussion board).  
Please email me the completed exam as a PLAIN TEXT file, from this machine.  
This is a UNIX course, so that shouldn't be a problem.  If the file is not a 
plain text file, or has extra junk (such as html'ish looking stuff, or goofy 
email headers or tails) then I will take 5 points of the grade.  To make sure 
you are doing this correctly, simply mail it to yourself once and take 
a look.  If you have any trouble, please feel free to ask for help 
mailing.  And, please use the email subject header - 90311 midterm

cut here
*******************************
Note:  A "single UNIX command" means exactly that, one command.
       A "single command string" means you can have more than one command
       connected with pipes.  If you have any semicolons then that is
       more than one command string.

Name: Marc Parente
 
  1. Locate the command that will Display statistics on free disk space.

     A.) What command will do this?

     Create a command string that contains the above command and will
     display the disk space statistics in kilobytes

     B.) What command string will do this?
*******************************
A.)	df
B.)	df –k 	
*******************************
  2. You want to save from line #10 to line #30 from file1 to a new
     file called file2.  Use head and tail to do this with one command
     string (no ;'s)
*******************************
  2. head -30 file1 | tail -20 > file2
*******************************
  3. Execute the finger command as the following:
          finger smcgowan
     The output will contain the following line of text:

To put my C programming courses into Cyber-Ed format.

     From where is the finger command getting that line of text?
*******************************
  3. ~smcgowan/.project
*******************************
  4. Create a SINGLE command string that will locate all of the lines that
     do NOT contain the string  /usr  but must contain the string  ksh  within
     the file called /etc/passwd. Direct this output to a file called pout.

     A.) What command string will do this?

     B.) How many characters are in the file pout?
*******************************
A.)	grep ksh /etc/passwd | grep –v /usr /etc/passwd > pout
B.)	412 characters
*******************************
  5. In your home directory, create a directory called MID.
     cd to this directory.

     Create the following files:
          notes1a notes2 labs notes labnotes Notes1 Notes2

     Execute the following commands in the exact order specified:
          rm Notes2
          ls -ld labnotes notes2 notes
          cat labs notes labnotes

     Using ONLY history references and word identifiers, construct a command
     string that will remove the files called notes2 and labs.

     A.) What command string will do this?

     Construct a command string that will remove the files Notes1 and
     notes1a. This string MUST make use of the [ ].  (Please note that
     this question does NOT involve using history references)

     B.) What command string will do this?
*******************************
Put answer here
*******************************
  6. Create an alias called whopw that will do the following:

       grep the password file for your username to return your password 
       file entry.  Assume the following: once the alias works, you will
       be letting all of your friends copy and use it. In other words,
       the alias must locate their password entry when it is run by them
       without them having to make ANY changes to the alias.

       HINT: One way to solve this problem can be found by searching
       the man pages for the string 'who'

       What alias will do this?
*******************************
Put answer here
*******************************
  7. Normally, when you execute the man command, the output is displayed one
     page at a time.

     If you did not want the output of the man command to be displayed by
     pages, (ie you want all the output at once, as if you were cat'ing
     a file) what man command option would you use to prevent the paging?
*******************************
Put answer here
*******************************
  8. I have created an alias called class within my .mailrc file. The alias
     includes the addresses of all the students in the class as well as my
     address. Normally, when sending mail to an alias, the sender will not 
     receive a copy of the message even if the senders address is included
     in the alias.

     What mail internal variable do I need to set to insure that I
     receive a copy of the mail message too?

     (Note:  we are talking about the "Mail" or "mailx" command, not "mail")
*******************************
Put answer here
*******************************
  9. Consider the following command string.
          cat > aa < mfile1

     A) What is the effect of the redirection characters? Be specific and
        mention each redirect in your answer.

     B) Write another unix command that will accomplish the same thing.
        (Do not use cat or either redirect)
*******************************
Put answer here
*******************************
 10. cd to ~smcgowan/Cyber/Unix. This directory contains a number of files.

     What combination of option flags, when used with the ls command,
     will generate the output in the following format?

     Please note that this ouput is old, so you can IGNORE any date/time 
     field defferences or disregard the fact that there may be a missing
     or extra file or two.  The point is to get the correct type and
     format of the output.

total 92
-rw-r--r--   2 10013    200        28744 Jan 16  2000 vitutor
drwxr-xr-x   3 10013    200          512 Jun  1  1999 TarDir/
lrwxrwxrwx   1 10013    200           38 Sep  2  2005 Scripts -> /users/faculty/smcgowan/Spring/Scripts/
drwxr-xr-x   2 10013    200          512 Jul 26  2000 Practice/
-rw-r--r--   1 10013    200           21 Jun  1  1999 numdata
drwxr-xr-x   2 10013    200          512 Nov 10 19:46 Links/
drwxr-xr-x   2 10013    200          512 Mar  6 15:24 Junk/
-rwxr-xr-x   1 10013    200          536 Sep 30  1999 greeting*
-rw-r--r--   1 10013    200          749 Mar  4 23:04 grades.dat
lrwxrwxrwx   1 10013    200            7 Sep  2  2005 for-midterm -> numdata
drwxr-xr-x   4 10013    200          512 Dec 19 22:52 Final/
drwxr-xr-x   3 10013    200         1024 Feb 14 20:32 FAQ/
drwxr-xr-x   5 10013    200          512 Oct 20  2003 Extra/
drwxr-xr-x   2 10013    200          512 May  6  2006 Data/
-rwxr-xr-x   1 10013    200           47 Sep 15  2004 csh.cshrc*
-rw-r--r--   1 10013    200          191 Jun  1  1999 autos
drwxr-xr-x   6 10013    200          512 Sep 12 21:42 ../
drwxr-xr-x  10 10013    200          512 Mar  4 23:04 ./

*******************************
Put answer here
*******************************