Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For problem A only use sed, grep -f and bash (to launch them) Problem A: sed and grep -f We need a new mechanism to

For problem A only use sed, grep -f and bash (to launch them)

Problem A: sed and grep -f We need a new mechanism to identify accounts that haven't been used in a while so that we can remove the accounts. We will use the lastlog tool to get information of the last time someone logged in; however, it just handles one server.

image text in transcribed Find anyone who has either not logged in or hasn't logged in during 2017 for each of those lastlog files. In the example above, the following users meet the criteria: ums562, xyz222, fernandez, and ytang. The result file should only contain user IDs.

The intersection of those result files gives us the people who didn't log into both of those servers during the desired time.

Matching on 2017. Where is the 2017 we want to match which indicates that the user logged in during 2017? If we just match "2017", it could match actual login IDs that contain 2017 who haven't logged in during 2017.

Intersection. Use grep -f to help with getting the intersection. Unfortunately, some login IDs like "lp" could match an id like "lpt913". There are several ways to avoid this problem. Consider having two different sed scripts (one for each of the lastlog?.out files). One of the scripts could produce output which tell the pattern to match to the end of the line: ytang$ lp$ The other sed script produces user IDs without the "$". Now the pattern lp$ doesn't match lpt913.

for problem B only use sed, cat, sort, uniq -c, and bash (to launch them)

Problem B: sed, cat, sort, and uniq -c For this problem, we will want to get the same result, but with a different approach. Using one of the sed scripts from problem A, we can produce two files of user IDs that either have not logged in or haven't logged in during 2017 (i.e., we won't have a pattern like "lp$" in our files). Suppose we cat those files together and sort them. We can use uniq -c to get a count of each unique value We can then use sed to include only user IDs with a count of 2 and also remove the count.

Although not required, you probably should diff the outputs of the two solutions. Note that you may have to sort the output of problem A before doing the diff.

lastlog1.out

Username Port From Latest root pts/6 crush.cs.utsarr. Tue Aug 15 10:52:33 -0500 2017 daemon **Never logged in** bin **Never logged in** sys **Never logged in** sync **Never logged in** games **Never logged in** man **Never logged in** lp **Never logged in** mail **Never logged in** news **Never logged in** uucp **Never logged in** proxy **Never logged in** www-data **Never logged in** backup **Never logged in** list **Never logged in** irc **Never logged in** gnats **Never logged in** nobody **Never logged in** libuuid **Never logged in** syslog **Never logged in** messagebus **Never logged in** landscape **Never logged in** sshd **Never logged in** ubuntu pts/0 mangw.cs.utsarr. Wed Dec 16 16:49:41 -0600 2015

statd **Never logged in** usbmux **Never logged in**

lastlog2.out

Username Port From Latest root pts/0 crush.cs.utsarr. Tue Aug 15 09:47:07 -0500 2017 daemon **Never logged in** bin **Never logged in** sys **Never logged in** sync **Never logged in** games **Never logged in** man **Never logged in** lp **Never logged in** mail **Never logged in** news **Never logged in** uucp **Never logged in** proxy **Never logged in** www-data **Never logged in** backup **Never logged in** list **Never logged in** irc **Never logged in** gnats **Never logged in** nobody **Never logged in** libuuid **Never logged in** syslog **Never logged in** messagebus **Never logged in** landscape **Never logged in** sshd **Never logged in** ubuntu pts/0 mangw.cs.utsarr. Wed Dec 16 16:49:41 -0600 2015 statd **Never logged in** usbmux **Never logged in**

Please note that lastlog returns a result similar to this: ums562 **Never logged in* pts/3 173.227.72.99 Sun Aug 7 11:39:56 -0500 2015 pts/11 n0000d193.cs.uts Wed Jan 13 11:13:49 -0600 2016 pts/2 104.218.77.194Tue Aug 15 10:11:37 -0500 2017 pts/8 172.24.141.44Fri Aug 18 13:07:29 -0500 2017 222 rslavin slark xtang **Never logged in

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

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions