Week 6 Homework

CS 345 Week 6 Homework

1 – 5) Finally! You get to prove your scripting skills since I know you’ve been chomping at the bit to do so. I would like you to create a script called tell that when run, does a variety of tasks:

A) You will need to use loop across each user that is currently logged in on the system.
B) For each user logged in, you will print information out about the user: their login name, real name, where they are logged in from, how long they have been logged in and where their home directory is located. You can mostly get this information from the who and finger commands that we talked about way back in week one.
C) Next we want to print out the amount of diskspace that a particular user is consuming in his/her home directory with files. Print out each file and its size in K, and then at the end print out a grand total of diskspace used in K as well. Your friends find and du will serve you well in this effort.
D) Print out whatever processes are owned by the user. With a little bit of help from man you can create the cascading print to show nested processes like what I am showing in my output.
E) Finally, consulting top would let you determine how much CPU time and memory the user is consuming. Print that information out in a nice concise format.

A) You may need to use the cut command to remove extraneous punctuation or ends of lines. You’ll want to read up on this command in man and try it outside of the script to see how it works.
B) You’ll find the awk command useful for printing out a specific column of output from a command that returns multiple columns. For example piping some output to awk in the form of command | awk ’{print $4}’ would print out the fourth column of information that the command generated.
C) The awk command can also be told to count and print when done counting as in command | awk ‘{ cnt = cnt+$1 } END {print “Count is : “,cnt}’

6) Write a script file to check for SetUID programs 4755.

7) Create a text file and make it a SetUID program.

8) Prove your script file works.

9) Use at to run your script 3 minutes from now.

10) Show how to run your script every night at 12:34 in the morning via cron.

11) Explain the purpose of a print filter and compare it to the idea of Windows printer drivers.

12) What does a printcap file contain?

13) How would you shut down a print queue that’s gone awry?

14) Show an example of a how a user can delete their own print jobs.

15) Are print quotas necessary? Why or why not?

New Download