Lab 8 - UNIX Commands

  1. The echo command takes a line that you type and repeats it back on the screen. Redirect your input line to a file named myFile.
  2. Use the echo command to input 5 more lines and redirect them to file myFile, which will contain a total of 6 lines of text.
  3. Using the commands who, who am i, and date, append to file myFile the outputs of the above commands.
  4. Suppose myFile is in your working directory. Specify the command(s) you would use to do the following:
    1. Give everyone permission to read myFile; do not change any other privileges.
    2. Permit the owner (you) and group members to read and write the file; remove all privileges from everyone else.
    3. Remove writing privileges from everyone but the owner.
    4. Give the owner and group members permission to execute myFile, while giving the owner sole permission to read and write the file.
  5. Suppose you have a directory named myStuff in your working directory. Specify the command(s) you would use to do the following:
    1. Give everyone permission to list files in myStuff; do not change any other privileges.
    2. Permit the owner and group members to list, remove, or add files; remove all privileges from everyone else.
    3. Remove writing privileges from everyone but the owner.
    4. Give the owner and group members permission to execute myStuff, while giving the owner sole permission to read and write the directory.
  6. Create a set of text files and name them backgammon, backpacking, baseball, boxing, biking, chess, fencing, blackjack, groupA, groupB, groupX, groupY.
    1. How would you use cat to show the contents of the files ending in ing?
    2. How would you list any files containg x or X in the file names?
    3. How would you show the contents of files with names containing o?
    4. How would you show the contents of the files backgammon, backpacking and blackjack using just one command?
    5. How would you copy the contents of all 3 files backgammon, backpacking and blackjack to a file named all3 using just one command?
  7. Given the file phone_book, specify the command(s) you would use to do the following:
    1. Display entries of people whose names contain pattern .alex., case-insensitive. (The output should be the entries of alex johnson and Alexander Smith.)
    2. Count the number of people who area code is 905. Display just the count (not the entries).
    3. Display the entries of the babysitters.
    4. Count the number of friends whose names are in phone_book. Display just the count (not the entries).