User Tools

Site Tools


cs370:cs_370_assignments

CS 370 List of Assignments


Collection Setup

During the semester, I will collect your homework and projects from your school UNIX home directory.

After logging into a lab machine or server, create either a cs370 or se370 directory inside your home directory (~) by running the command:

mkdir ~/cs370

or

mkdir ~/se370

Then run either of the following commands:

submit.cs370

or

submit.se370

The submit… command should be run after you add any new files or directories under your cs370 or se370 subdirectory. This will make your class directory available to me; they will not be accessible to other students.


Assignment 1

Deadline: Mon, May 27, 11:59pm

Setup: You will need to access your UNIX account. Create the assignments/1/ directory inside your course directory (cs370 or se370).

1.

A key principle of UNIX design is that everything is (or should be) text. See p. 17 of the textbook (Determining a File's Type with file and What is “Text”?). Identify an ASCII text file in your home directory (not one that you created or modified), and copy that file into the assignments/1/ directory. Note: The ls -a command finds hidden files.

2.

See pp. 34-41 of the textbook. To learn basic UNIX file management commands, run all the commands given in the “Let's Build A Playground” exercise. To prove that you have gone through the entire exercise, run

history -w playground_history

to write your shell command history to the file playground_history, and then copy playground_history into the assignments/1/ directory.

3.

Login to the plato.monmouth.edu server (A.K.A. aristotleii). Leave a trace of your visit in the /tmp directory of plato, i.e., create a small file in the /tmp directory before you log out. The filename must contain your student id.


Assignment 2

Deadline: Tue, Jun 4, 11:59pm

Setup: You will need to access your school Unix account. Create the assignments/2/ directory inside your course directory (cs370 or se370).

Write your name, student ID and your answers in the plain text file asn2.txt. Number each answer. Save asn2.txt in the directory for Assignment 2. Note: Some questions require you to create an additional file or symbolic link in the Assignment 2 directory.

1.

Include the hostname of the Linux machine you are using for this question. Does the nano editor have undo/redo functionality? If it does, how do you use it? How did you figure it out?

2.

Backup your shell config (~/.bashrc) using cp. The backup copy must have the name .bashrc.bak. Copy .bashrc.bak to the directory for Assignment 2.

3.

If you have not generated a SSH key pair in your UNIX account, do so now. Create a valid symbolic link to your ssh public key file (not the private key file) in the directory for Assignment 2. (See the book, page 38.)

4.

How can you use ls without any colorization of output? How did you find the correct ls command line option?

5.

Commands such as ls, cp, mkdir, mv, rm and ps have a command line option that shows command usage and a listing and description of all command options. What is that command line option? (See the book, chapter 5.)

6.

Say that your present working directory is

/usr/local/src/system/unison-2.48.3/uimac14/Frameworks/Growl.framework/Versions/Current/Resources

What is the easiest (shortest) way to change to the directory

/usr/local/src/system/unison-2.48.3/uimac14/Frameworks/Growl.framework/Versions

? (See the book, chapter 2.)

7.

Say that you have defined the alias

alias confshell='nano ~/.bashrc'

In that alias, is ~/.bashrc an absolute or relative pathname?

Why is it a good idea to use ~/.bashrc instead of just .bashrc with this alias? (See the book, chapter 2.)

8.

My ~/.bashrc file has the following lines in it

# Commands to run with every new shell (jchung, 9/2017)
echo; fortune 2> /dev/null

What would be the purpose of ending the fortune command with 2> /dev/null. (See the book, chapter 6.)


Assignment 3

Deadline: Thu, Jun 20, 11:59pm

Setup: You will need to access your UNIX account. Create the assignments/3/ directory inside your course directory (cs370 or se370).

Write your name, student ID and your answers (where applicable) in the plain text file asn3.txt. Number each answer. Save asn3.txt in the directory for Assignment 3. Note: Some questions require you to copy a file into your Assignment 3 directory.

1.

How can grep be used to see if a text pattern exists in a shell variable? For example, say that the variable $LANGUAGE can contain the name of some language. How could grep be used to check if $LANGUAGE contains “portugese”?

2.

The fortune command has an option that allows searching for fortunes that match a text or regular expression pattern. How can fortune be run to find all fortunes that contain the word “bulwer”, ignoring case? How do you use grep and wc to count the number of fortunes that contain the word “bulwer”?

3.

(See chapter 13 of the book.) The $HOSTNAME environment variable contains the hostname of the Unix system that you are logged into. Write an if or case structure that changes the color of your command prompt $PS1 depending on which host you are logged into. Use the following table:

        Hostname	Color in PS1
        --------        ------------
        rockhopper	Light Gray
        aristotleii	Light Blue
        all others	Green

Your $PS1 environment var must continue to show your userid@hostname and pwd (present working directory), but with added color.

Add the if or case structure to your ~/.bashrc. Copy your modified ~/.bashrc to your Assignment 3 directory. The modified ~/.bashrc is your answer for question 3.

4.

Modify the script in the for structure Example 3 (ping-hh305.sh script) so that the script's only output consists of machines in HH305 that do not respond to a ping. Example script output:

      HH305-19ML65677 not responding
      HH305-18ML65676 not responding
      HH305-17ML65675 not responding

Notes: In the modified ping-hh305.sh script, suppress all output (stdout & stderr) from ping. Use the ping exit status ($?). Use an if statement or conditional chaining. Copy your modified ping-hh305.sh script into your Assignment 3 directory.

5.

Complete the roster processing exercise, without using awk. Write your new pipeline as your answer.

6.

How can the seq command be used in a command substitution to make the variable $list_of_hostnums contain

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

?

See the --help command line option or the seq command's manual page.

7.

Write the definition of a shell function called anticaps that takes a string as an argument and converts all but the first character to lower case. The function would work as follows:

anticaps "BUZZFEED"

Output: Buzzfeed

Use the cut and tr text processing utilities in your function definition. You may also use parameter expansion as an alternative to cut.


cs370/cs_370_assignments.txt · Last modified: 2024/06/13 19:36 by jchung

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki