Assignment #2

Name:


Full E-mail Address:


UNIX System Used:



1. (a)  Create a file called bethere1 in your present working directory and
        set its access permissions to read, write, execute for yourself, write 
        for the users in your group, and read and execute for other users.
        What command did you use to set privileges? Give another command
        that accomplishes the same thing.
   (b)  The user newkatz sets access permissions for his home directory by
        using the chmod 700 $HOME command. If the file cp.old, there, 
	has permissions equivalent to 155, which categories of users can or
        cannot read this file?  Explain why they can or cannot.
   (c)  What umask command should be executed to set the permissions 
        bit mask to 264?  With this mask, what default access privileges are
        associated with any new file that you create on the system? Why?
        Where would you put this command so that every time you log onto
        the system this mask is effective?

2. (a) Type $ cd <CR> then list the contents of the directory
     ../../../usr/teacher/abcd1 . What is shown?
     (b) Change your current directory to ../../../usr/teacher/abcd1 . 
     What happens?
     (c) Type $ cd <CR> then list the contents of the directory
     ../../../usr/teacher/abcd2 . What is shown?
     (d) Change your current directory to ../../../usr/teacher/abcd2 . 
     What happens?
     (e) Type $ cd <CR> then list the contents of the directory 
     ../../../usr/teacher/abcd3 . What is shown?
     (f) Change your current directory to ../../../usr/teacher/abcd3 . 
     What happens?

3. (a) Give a commandline for displaying all files in a directory
       that either start with or end with: 	abc   or   .htm
   (b) Write a commandline, using Braces Substitution: { }
       that produces the output: 
	Hello, Elmer Smith and Olga Smith!
   (c) Write down the line in the /etc/passwd file on ned
       that contains information about your userid. What are your
       login shell, password field contents, UID number and GID number?
   (d) What would happen if the last field for your userid in /etc/passwd
       were replaced with /bin/pwd? Why would it happen?

II. Answer these questions with a single UNIX command using combinations of 
unix tools.  Copy the file: /usr/teacher/wordsfile into your Assignment2 
directory.  For these questions, both the command and the output are 
required to answer the question.

4. How many lines in wordsfile start with 'f' or 'F' ?

5. How many empty lines are in wordsfile ?

6.  Determine (by a command, not by inspection) whether wordsfile is already 
sorted into descending alphabetical order.  

7.  Determine (by a command, not by inspection) whether every line of 
wordsfile is different.

8.  List all the different last letters of words in wordsfile in decreasing 
order of frequency.

9.  For words ending with the letter 'S' or 's' in wordsfile, list each 
different previous letter (only) that comes before the letter 'S' or 's' in 
decreasing order of frequency.

III. For these questions, invoke the vi editor.
10.  How do you do the following:  Consider all the (reasonable) ways
    for fixing the following sentence: 

          Your lucky number is 3552664958674928.  Waacth for it everywhere.
  
    There is one method that requires only 3 keystrokes once the 
    cursor is properly positioned.  What is that method?

11.  What do each of the following regular expressions mean?
          (a) u 
          (b) . 
          (c) [A-Z ]*..[t-z:!]
          (d) [a-z]  
          (e) [a-z]* 
          (f) [a-z][a-z]* 
          (g) [^a-z]* 
          (h) .\.* 
          (i) e.*e

12.  What parts of the following line:

People often find it easier to be a past result than a cause of the future!

    will be matched by each of the regular expressions listed in question 11?

Questions about the questions? Send mail to Robert Katz: rkatz@ned.highline.edu
Last Update February 8, 2005