Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part I: Build a user reference data file with the usernames and full names by ex

ID: 2246331 • Letter: P

Question

Part I:

Build a user reference data file with the usernames and full names by extracting the necessary information from the /etc/passwd file.

Sort the /etc/passwd and get line 100-110 of that file. Use the cut command to extract the username from /etc/passwd. Save the result file as ids.

Create another file called names which contain full names of line 100-110 of sorted /etc/passwd in a similar way.

Use the paste command to combine the two files, ids and names, together side-by-side as shown below, redirect the output to a file called users.ref. For ease of processing, separate the two fields with a space. If there is any ‘,’ in the file, use an editor to get rid of them. The final version of users.ref should look like the following format:

sally.black Sally Black

jane.smith Jane Smith

lily.brown Lily Brown

Before you continue with Part II, it is a good idea to save a copy of users.ref. You will know why when you accidentally erase the contents of the data file.

Part II:

For the following steps, write shell programs that use command line arguments as input to the shell program. Do not prompt the user for input from the keyboard!

Note: Most of these shell programs need to be only 1 or 2 lines long.

Write a shell program called list to display all the usernames and full names in the users.ref file. The information should be displayed in alphabetical order by student's last name (not by username). Save the list shell program in your lab7 directory.

Write a shell program called find to locate an existing record in users.ref and display the student's username and full name on the screen. The search should not be case sensitive. This shell program should allow the user to specify either a student's username or their full name. Save the find shell program in the lab7 directory.

   $ find "lily.brown"   or   $ find 'Lily Brown'

Did you encounter any problems in the previous step? If so, what were they and how did you resolve them? Include a note describing the problems and solutions in a file called lab7.notes.

Write a shell program called remove which deletes a student's entry from your users.ref file. Similar to find, the user should be able to specify the student to be removed by their username or their full name. Save the remove shell program in lab7. (hint: grep has an option "-v". Go check it out!)

Write a shell program called add to add a new username and full student's name to your users.ref file. Your program should be used in the following manner (hint: echo hello >> file):

$ add woody.brown 'Woody Brown'

Part III:

Verify correct operation of your shell programs. Use the script command to record your test results. Type script at the command line. This will start a new shell that "captures" all input and output and records it in a file named typescript in your current directory.

Execute the pwd command.

Execute the ls command.

Execute your list command.

Execute your find command (or whatever you named it) twice. (Once to locate a student by their username and a second time to locate them by their full name.)

Use your remove shell program twice: once to remove a student using their username, another removing them by their full name.

Use your add shell program to add an entry to the file

Execute your list command a second time.

Type exit (or ctrl-d) to exit the script shell. The input and output were written to a file called typescript. Change the name of this file to script1 and save it in the lab7directory.

Can anyone tell me the steps to do this by picture?

Explanation / Answer

Part I:

Utilizing the/and so on/passwd record

Customarily, the/and so on/passwd record is utilized to monitor each enlisted client that approaches a framework.

The/and so on/passwd document is a colon-isolated record that contains the accompanying data:

•        User name

•        Encrypted secret word

•        User ID number (UID)

•        User's gathering ID number (GID)

•        Full name of the client (GECOS)

•        User home index

•        Login shell

The accompanying is a case of a/and so on/passwd document:

Root:!:0:0:: /:/usr/canister/ksh

Daemon:!:1:1::/and so on:

Bin:!:2:2:: /canister:

Sys:!:3:3::/usr/sys:

Adm:!:4:4::/var/adm:

Uucp:!:5:5::/usr/lib/uucp:

Guest:!:100:100::/home/visitor:

Nobody:!:4294967294:4294967294::/:

lpd:!:9:4294967294::/:

LP:*:11:11::/var/spool/lp:/canister/false

Invscout:*:200:1:: /var/adm/invscout:/usr/canister/ksh

Nuucp:*:6:5: uucp login client:/var/spool/uucppublic:/usr/sbin/uucp/uucico

Paul:!:201:1::/home/Paul:/usr/canister/ksh

Jdoe:*:202:1: John Doe: /home/jdoe: /usr/canister/ksh

AIX® does not store scrambled passwords in the/and so on/secret key document in the way that UNIX frameworks do, however in the/and so forth/security/watchword 1 record as a matter of course, which is just lucid by the root client. The secret word documented in/and so on/passwd is utilized by AIX to imply if there is a watchword or whether the record is blocked.

The/and so on/passwd document is possessed by the root client and must be intelligible by every one of the clients, yet just the root client has writable consents, which is appeared as - rw-r- - r- - . In the event that a client ID has a secret word, at that point the watchword field will have a! (Outcry point). In the event that the client ID does not have a secret word, at that point the watchword field will have a * (reference bullet). The scrambled passwords are put away in the/and so forth/security/passwd document. The accompanying case contains the last four sections in the/and so on/security/passwd document in view of the passages from the/and so on/passwd record indicated already.

Visitor:

Secret key = *

No one:

Secret key = *

Led:

Secret key = *

Paul:

Secret key = eacVScDKri4s6

Last update = 1026394230

Banners = ADMCHG

The client ID jdoe does not have a passage in the/and so on/security/passwd record since it doesn't have a secret word set in the/and so forth/passwd document.

The consistency of the/and so on/passwd document can be checked utilizing the pwdck order. The pwdck charge confirms the accuracy of the secret word data in the client database documents by checking the definitions for the majority of the clients or for determined clients.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote