Lab Worksheet, Foundations of Computing, Week 4 -- Jan 30, 2001

  1. A user creates (or obtains) a file of shell commands named cmds and puts it in the working directory. The user attempts to execute the file, but gets an error message:

    
       $ cmds
    
       bash: cmds: command not found 
    
    
    1. What's wrong?

    2. What command can the user type instead of cmds to avoid this problem?

  2. The user types the corrected command, but this time gets another error message that ends permission denied.

    1. What's wrong now?

    2. What command can the user type to fix this problem?

  3. The script cmds reads from the standard input and writes to the standard output. What command should the user type to run cmds, to read from and write to the specified locations:

    1. Read from the keyboard, write to the screen

    2. Read from file infile, write to the screen

    3. Read from the keyboard, write to the new file outfile

    4. Read from file infile, write to the new file outfile

    5. Read from the keyboard, write to the end of the old file logfile

  4. The Unix command cat simply copies its input to the standard output. It may take its input from the standard input, or it may take its input from all the files provided as command line arguments. What is the effect of each of these commands?

    1. cat foo

    2. cat < foo

    3. cat > foo

    4. cat * > foo

    5. cat foo > bar

    6. cat foo bar | wc

  5. There is a sorted dictionary of words (one word per line) in /usr/dict/words. Some of the words in the dictionary are capitalized.

    1. What command shows the number of words in the dictionary?

    2. What command shows the words in the dictionary that contain the lowercase letter x?

    3. What command shows the number of words in the dictionary that contain the lowercase letter x?

    4. What command shows the words in the dictionary that begin with the letter x, lowercase or upper case?

    5. What command shows the number of four-letter words in the dictionary?

  6. Say you wish to prevent other users from seeing what files you have and from reading most of your files, but you want to allow them to copy one file named pub in your home directory. However you do not want to allow them to change this file.

    1. What command shows the protection on your home directory?

    2. Say you execute this command and it shows drwxr-xr-x. Can other users see what files you have? Explain your answer.


    3. What command can you use to prevent other users from seeing what files you have, but will still allow them to copy your pub file?


    4. What command shows the protection on your pub file?

    5. Say you execute this command and it shows drwxrwxr-x. Can other users copy this file? Explain your answer.


    6. Can other users change your pub file? Explain your answer.


    7. What command can you use to prevent other users from changing your pub file, but still allow them to copy it?


  7. What is the value of the binary number 101 in decimal? In octal?