CS2718 Assignment 5

Your Name -- Your Student Number

Complete this assignment by downloading this HTML file and editing it (using a text editor---not a special HTML editor). Wherever you see emphasized text (e.g. "Your name" and "Your Student Number" above) you should insert your own text, as appropriate. Submit via D2L by 5:00 p.m. on Wednesday, March 9.

PIDs

Examine the Wikipedia article on process identifiers. What is special about the process on Linux whose PID is 1?

*Change this with your answer*

PS Headings

Briefly describe the following ps aux headings:

  1. USER

    Change this with your answer

  2. %CPU

    Change this with your answer

  3. VSZ

    Change this with your answer

  4. TTY

    Change this with your answer

  5. TIME

    Change this with your answer

Load Averages for top

Briefly describe the load averages displayed by top.

*Change this with your answer*

Foreground and Background Processes

In Bash, what is the difference between a foreground process and a background process.

*Change this with your answer*

Foreground and Background Processes

When using the kill command, what is the difference between the KILL and TERM signals?

*Change this with your answer*

Library Notice

Write a Bash script that produces:

Hello Your Name,
    Please return, 'late book', before Tuesday.

Library Staff

when run with:

$ ./late.sh "Your Name" "late book" Tuesday

Provide your source code below.

*Change this with your answer*

Counting characters

The following wc command

$ wc -c < foo
38

outputs 38 if foo contains 38 characters.

The output of the command above can be captured by:

$ c1=$(wc -c < foo)

Using a modification of the strategy above and arithmetic shell expansion, write a script that counts the number of characters in three files. Running the following script should produce

$ ./count3.sh foo bar foo
86

assuming foo has 38 characters and bar has 10 characters.

Give the code for count3.sh.

*Change this with your answer*

Create Directories

A listing of the directory foo with the command ls -FR foo produces:

foo:
one/ three/ two/

foo/one:
xx/

foo/one/xx:

foo/three:

foo/two:
yy/

foo/two/yy:

Write a script, called createdir.sh, that produces the above directory tree when run with:

$ ./createdir.sh foo xx yy

Provide the code for createdir.sh below:

*Change this with your answer*

Count Colours

Write a script that generates the following report when run with ./rgb_freq.sh filename

'filename' has 4 occurrences of red
'filename' has 0 occurrences of green
'filename' has 7 occurrences of blue

Assuming filename contains red 4 times and blue 7 times.

Provide the code for rgb_freq.sh below.

*Change this with your answer*