Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are asked to write a shell script named rpsm.sh. The script reports and prints (to stdout) selected storage management information. Think of it as

You are asked to write a shell script named rpsm.sh. The script reports and prints (to stdout) selected storage management information. Think of it as RePort Storage Management.

The easy way to describe what the script needs to do is to look at what it should display in the case where you provide incorrect parameters, or in the case where you provide -h for help:

Usage: ./rpsm.sh < directory>

Reports selected information about specified directory tree.

Options:

-h Print this help message, i.e., Usage: ./rpsm.sh (except -h and -v)

-v Print script version information, i.e., 1.0

-u Find and list all files (just file names) with setuid set, all owners

-g Find and list all files (just file names) with setgid set, all owners

-w Find and list all files (just file names) that are world-writable

-b Find and list all files (just file names) whose size is at least 10M

-d Report directory disk usage

-i Report information about the file system

-a All of the above (except -h and -v)

There are files which match these criteria on the machine loki.ist.school.edu in the directory /home/user/CYBR. It might be easier to test your script against this directory instead of / for example because it will be much faster and you will not get a bunch of permission denied messages.

Grading rubrics:

Most of the options above are self-explanatory, but some are not, so let me provide examples for the latter case. The -d option should produce sorted output just like (may be more, not exactly the same as) the following. Hint: look at du command. Pay attention to the calculation in the last line regarding the total usage: 76 = 4+8+12+24+24 (we just need to consider all directories listed here).

user@loki:~$ ./rpsm.sh -d /home/user/CYBR/files

4 /home/user/CYBR/files/Perms

8 /home/user/CYBR/files/EnvDemo

12 /home/user/CYBR/files/BigFiles

24 /home/user/CYBR/files/SomeSetgids

24 /home/user/CYBR/files/SomeSetuids

76 /home/user/CYBR/files

The -i option shows me information about the file system holding the directory I am asking about. (Hint: look at the df command.) It does not give me all of the information but it should look just like the following. You control the spaces or tabs between two columns, but should make it read clearly.

user@loki:~$ ./rpsm.sh -i /home/ user/CYBR

Filesystem Type Use% Mounted on

prog.ist.school.edu:/home nfs4 52% /home

Again, you will want to figure out how to get the information and then also how to cut it up. Heres another example regarding the combination of two options -i and then -d:

user@loki:~$ ./rpsm.sh -id /etc

Filesystem Type Use% Mounted on

/dev/mapper/loki-root ext4 28% /

4 /etc/apache2/sites-enabled

4 /etc/apparmor.d/disable

4 /etc/apparmor.d/force-complain

4 /etc/apparmor.d/tunables/multiarch.d

4 /etc/apparmor/init/network-interface-security

Youll note that the output for -id versus -di would be different because of the order of the command line arguments. Also note that you need to handle -, for instance -id as the same as -i -d. We have already covered getopts in this class - use it!

And ./rpsm.sh -i -d ~ is equivalent to ./rpsm.sh -id ~, ./rpsm.sh -d -i ~ is equivalent to ./rpsm.sh -di ~.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

What were the issues and solutions proposed by each team?

Answered: 1 week ago

Question

3. Who would the members be?

Answered: 1 week ago